The string manipulation functions commonly used in LoadRunner are:
strcpy (destination_string, source_string);
strcat (string_that_gets_appended, string_that_is_appended); 51Testing Software Test Network: j3~c:c[(wr%a2l
Atoi (String_to_convert_to_int); Returns the integer value
Itoa (integer_to_conver_to_string, destination_string, base); Base is 10
strcmp (string1, string2);//returns 0 if both strings is equal51Testing software test network Q%usek
The definition of each function:
strcpy (): Copies a string into another string.
Strcat (): Adds a string to the end of another string.
strcmp (): Compares two strings, if equal returns 0.
Atoi (): Converts an ASCII string to an integral type.
itoa (): Converts an integer data to an ASCII string 51Testing software test network based on the given input d&vi2kd|
The following example uses the above functions:
Actions () {Charmystring1[ -] =""; Charmystring2[ -] =""; Charmystring3[ -] ="Mercury2"; Charcstring[Ten] ="12345"; intCint; //MyString1 is empty//Lr_output_message (">>>>>>>>>> MyString1 =%s", MyString1); //copy "Mercury1" into MyString1//strcpy (MyString1,"Mercury1"); //Now MyString1 contains "Mercury1"//Lr_output_message (">>>>>>>>>> MyString1 =%s", MyString1); //Copy MyString3 into MyString2//Lr_output_message (">>>>>>>>>> MyString2 =%s", MyString2); strcpy (MYSTRING2,MYSTRING3); Lr_output_message (">>>>>>>>>> MyString2 =%s", MyString2); //Catenate MyString2 to MyString1//strcat (MYSTRING1,MYSTRING2); Lr_output_message (">>>>>>>>>> MyString1 =%s", MyString1); //Cstring is converted to integer Cint//Lr_output_message (">>>>>>>>>> Cstring =%s", Cstring); Cint=atoi (Cstring); Lr_output_message (">>>>>>>>>> Cint =%d", Cint); //Cint is converted to stringCint= -; Itoa (cint,cstring,Ten); Lr_output_message (">>>>>>>>>> Cstring =%s", Cstring); return 0;}
String manipulation functions commonly used in LoadRunner