51Testing软件测试论坛

标题: LoadRunner:RTE if statement [打印本页]

作者: pcl2004_27    时间: 2006-10-25 14:19
标题: LoadRunner:RTE if statement
Description

      Need to use the strcmp function in order to compare values.


Solution

      From discussion forum:
Dec 01 2000 : Tim Kriksciun

RTE conditional 'if' statement

I am attempting to perform the following simple conditional statement in the action() section of an RTE script in VUGen.

char msg[] = "Ds";
char dupe[] = "Ds";

lr_message("msg: %s", msg);
lr_message("dupe: %s", dupe);

if (msg == dupe){
lr_message("Dupe");
}
else{
lr_message("Nope");
}

It does not appear that the 'if' conditional statement is being evaluated as the execution log reports the following results:

msg: Ds
dupe: Ds
Nope

Solution:
Dec 01 2000 : Jason Craven

RTE conditional 'if' statement
You have to compare the strings in a different way:

...
if (strcmp(msg, dupe) == 0){
lr_message("Dupe");
}...

Hope this helps.




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2