c语言在loadrunner中应用-break-exit和continue-skip
上一篇 /
下一篇 2007-07-23 17:20:22
学习地址:http://tech.groups.yahoo.com/group/LoadRunnerCN/message/30
继续“c语言在
loadrunner中应用”的学习,此次学习的内容是c语言中的break及continue对流程的控制在loadrunner中怎样实现的。具体内容摘录如下:
break and continue
C provides two commands to control how we loop:
break -- exit form loop or switch.This applies only to for/while loops. To break out of a LoadRunner iteration, use
exit(-1);
continue -- skip 1 iteration of loop.This applies only to for/while. To continue to the next iteration in LoadRunner iterations, use
return 0.
You will find these very useful when you have to conditionally break out of a LoadRunner iteration or exit out of a scrīpt. The following example should illustrate the use of exit and continue in LoadRunner.
从上述描述了解到c语言提供了break和contuine两个命令用来控制循环,对于loadrunner,对应的实现方式是exit(-1)和return 0。exit(-1)直接退出脚本;return 0 忽略其后面语句的执行,直接进行下一次迭代。如何结合for/while循环使用exit与return合理地描述业务流程,将在以后的学习中实践。文章中的示例如下:
// Global variable count
int count=0;
Actions()
{
// Increment count
//
count++;
// If count is equal to 10, exit the scrīpt
//
if(count == 10)
exit(-1);
// If count is even, skip the current iteration
// and continue with the next iteration
//
if(count%2 == 0)
return 0;
lr_output_message(">>>>>>>>>>>>>>>>>>>>>> %d",count);
return 0;
}
收藏
举报
TAG: