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, useexit(-1);
continue -- skip 1 iteration of loop.This applies only to for/while. To continue to the next iteration in LoadRunner iterations, usereturn 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:

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-06  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 19537
  • 日志数: 22
  • 书签数: 21
  • 建立时间: 2007-05-17
  • 更新时间: 2009-03-01

RSS订阅

Open Toolbar