#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;
}
The sample Loadrunner script below shows examples of FOR, DO and DO WHILE LOOPs.
最新推荐文章于 2025-11-06 13:08:54 发布
本文通过三种不同的循环结构(FOR循环、WHILE循环及DO-WHILE循环)演示了如何在程序中进行迭代操作。每种循环都实现了从1到10的计数,并通过输出消息显示当前的循环次数。
1万+

被折叠的 条评论
为什么被折叠?



