The sample Loadrunner script below shows examples of FOR, DO and DO WHILE LOOPs.

来源:互联网 发布:linux系统版本查看 编辑:程序博客网 时间:2024/05/01 19:29
#include "as_web.h"

int i;

// Set whileloop = 1 for the while loop example to work
int whileloop = 1;

Action()
{
//Example of a loop using a FOR loop
for (i=1;i<=10;i++)
{
lr_output_message( "FOR Loop number %d", i);
}


//Equivalent example but using a WHILE loop
//This can be made more complicated by including other conditions e.g. &&
i=1;
while ((i <= 10) && (whileloop ==1))
{
lr_output_message( "WHILE Loop number %d", i);
i++;
}


//Equivalent example but using a WHILE loop
//This can also be made more complicated by including other conditions e.g. &&
i=1;
do {
        lr_output_message( "DO WHILE Loop number %d", i);
i++;
}
while (i <= 10) ;


return 0;
}
原创粉丝点击