|
在action中定义变量,就运行不了,在Action外面定义,就可以运行,请高手解答,为什么呢?
在Action内部定义变量:
Action()
{
lr_load_dll("LR_USER_DLL.dll");
int a=5;
int b=6;
int sum=0;
sum=add(a,b);
lr_message("和为%d",sum);
return 0;
}
运行输出:
Action.c (6): illegal statement termination
Action.c (6): skipping `int'
Action.c (6): undeclared identifier `a'
Action.c (7): illegal statement termination
Action.c (7): skipping `int'
Action.c (7): undeclared identifier `b'
Action.c (8): illegal statement termination
Action.c (8): skipping `int'
Action.c (8): undeclared identifier `sum'
d:\\program files\\mercury\\loadrunner\\scripts\\http\\\\combined_http.c (5): 9 errors, not writing pre_cci.ci
将变量定义移动到action外面,就可以运行,得到正确结果。
int a=5;
int b=6;
int sum=0;
Action()
{
lr_load_dll("LR_USER_DLL.dll");
sum=add(a,b);
lr_message("和为%d",sum);
return 0;
}
运行输出:
Virtual User Script started
Starting action vuser_init.
Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788 [MsgId: MMSG-27143]
Run-Time Settings file: "D:\Program Files\Mercury\LoadRunner\scripts\http\\default.cfg" [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
和为11
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated. |
|