String comparison function in LR

Hi,

Thanks in advance,

Can any one help on string comparison function otherthan strcmp to use in Load Runner scripting.

I need to compare a string with the value captured and saved in LR variable.

For Example :  result=strcmp((lr_eval_string("{c_planGroupVal}"),"DC")

Please suggest me with an alternate string comparison function which can be used in LR script.

Regards

Parents
  • Hello there, you didn't tell what property of strcmp you didn't like.

    Does it help you to look on strcmp() like working just like substraction? Comparing two numbers, using substraction and zero, you get operations which resemble the usage of strcmp, as you can see here:

    5 - 4 > 0   (while strcmp("ccc", "bbb") > 0) i.e., first argument is larger than the second

    4 - 4 = 0 (while strcmp("bbb", "bbb") = 0) i.e., both arguments are equal

    3 - 4 < 0 (while strcmp("aaa", "bbb") < 0) i.e., first argument is less than the second

     

    As you notice, you get a positive, zero or negative result in both cases. Also, don't forget functions like strlen("some string") or strstr("haystack with needle and thread", "needle") to see if you have a string at all or if the second string is part of the first..

Reply
  • Hello there, you didn't tell what property of strcmp you didn't like.

    Does it help you to look on strcmp() like working just like substraction? Comparing two numbers, using substraction and zero, you get operations which resemble the usage of strcmp, as you can see here:

    5 - 4 > 0   (while strcmp("ccc", "bbb") > 0) i.e., first argument is larger than the second

    4 - 4 = 0 (while strcmp("bbb", "bbb") = 0) i.e., both arguments are equal

    3 - 4 < 0 (while strcmp("aaa", "bbb") < 0) i.e., first argument is less than the second

     

    As you notice, you get a positive, zero or negative result in both cases. Also, don't forget functions like strlen("some string") or strstr("haystack with needle and thread", "needle") to see if you have a string at all or if the second string is part of the first..

Children
No Data