LoadRunner中提供了函数exit(-1)来结束迭代。 使用return 0 来结束本次迭代,进入下一次迭代。
  例子如下:
  在运行时设置中,设置迭代次数为5,运行下面的脚本:
  int i;
  char aaa[]="test";
  Action()
  {
  i=0;
  if (i==0) {
  exit(-1);
  }
  lr_output_message("value:%s",aaa);
  return 0;
  }
  结果为:
  Virtual User scrīpt started
  Starting action vuser_init.
  Ending action vuser_init.
  Running Vuser...
  Starting iteration 1.
  Starting action Action.
  只运行了一次迭代,结束了。
  下面的代码:
  int i;
  char aaa[]="test";
  Action()
  {
  i=0;
  if (i==0) {
  return 0;
  }
  lr_output_message("value:%s",aaa);
  return 0;
  }
  结果:
Virtual User scrīpt started
Starting action vuser_init.
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Ending action Action.
Ending iteration 1.
Starting iteration 2.
Starting action Action.
Ending action Action.
Ending iteration 2.
Starting iteration 3.
Starting action Action.
Ending action Action.
Ending iteration 3.
Starting iteration 4.
Starting action Action.
Ending action Action.
Ending iteration 4.
Starting iteration 5.
Starting action Action.
Ending action Action.
Ending iteration 5.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
  运行了5次迭代,但是每次迭代运行到lr_output_message("value:%s",aaa)之前都跳出迭代,进行下一次迭代。