一:
以下脚本,定义两个一样的字符数组,对比后,打印出result的值:
1. vuser_init()
2. {
3. int result;
4. char string1[] = "We can see the string:nancy";
5. char string2[] = "We can see the string:nancy";
6. lr_output_message("the string1 is %s.",string1);
7. lr_output_message("the string2 is %s.",string2);
8. result = strcmp(string1,string2);
9. if ( result == 0 )
10. {
11. lr_output_message("the result is 0.");
12. }
13. else
14. {
15. lr_output_message("the result is not 0.");
16. }
17. return 0;
18.}
复制代码
运行结果:
1. Starting action vuser_init.
2. Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788 [MsgId: MMSG-27143]
3. Run-Time Settings file: "C:\Documents and Settings\Zee\Local Settings\Temp\noname26\\default.cfg" [MsgId: MMSG-27141]
4. vuser_init.c(7): the string1 is We can see the string:nancy.
5. vuser_init.c(8): the string2 is We can see the string:nancy.
6. vuser_init.c(13): the result is 0.
7. Ending action vuser_init.
8. Running Vuser...
复制代码
二:
脚本:
1. vuser_init()
2. {
3. int result;
4. char string1;
5. char string2;
6. lr_save_string( "We can see the string:nancy","string1" );
7. lr_save_string( "We can see the string:nancy","string2" );
8. lr_output_message("the string1 is %s.",lr_eval_string("{string1}"));
9. lr_output_message("the string2 is %s.",lr_eval_string("{string2}"));
10.result = strcmp(lr_eval_string("{string1}"),lr_eval_string("{string2}"));
11. if ( result == 0 )
12. {
13. lr_output_message("the result is 0.");
14. }
15. else
16. {
17. lr_output_message("the result is not 0.");
18. }
19. return 0;
20.}
复制代码
结果:
1. Starting action vuser_init.
2. Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788 [MsgId: MMSG-27143]
3. Run-Time Settings file: "C:\Documents and Settings\Zee\Local Settings\Temp\noname26\\default.cfg" [MsgId: MMSG-27141]
4. vuser_init.c(10): the string1 is We can see the string:nancy.
5. vuser_init.c(11): the string2 is We can see the string:nancy.
6. vuser_init.c(16): the result is 0.
7. Ending action vuser_init.
8. Running Vuser...
复制代码