String Functions Present in Loadrunner

String Functions

Below are the most important list of string functions present in loadrunner.

lr_eval_string :

  • lr_eval_string function returns the input string after evaluating any embedded parameters.
  • So if the string argument contains only a parameter, the function returns the current value of the parameter.
  • Example : lr_save_int(47, "searchCount");

lr_save_string :

  • lr_save_string function assigns the specified null-terminated string to a parameter.
  • But the functions is useful in correlating queries.
  • Example : lr.save_string("John Doe" , "Student" );

lr_save_var :

  • lr_save_var function assigns the specified variable length string to a parameter.
  • So the function is useful in Correlating Statements.
  • But to determine the value of the parameter, use the lr_eval_string function.
  • Do not:
    • save an input buffer that contains null or other binary data.
    • pass a value_len longer than the actual data.
  • Example : lr_save_var( lr_eval_string("{InName}"),  MAX_NAME_LEN, 0, "ShortName");  // Save the first four characters of "InName" to "ShortName"

lr_save_datetime :

  • lr_save_datetime function saves the current date and time, or the date and time with the specified offset into a parameter.
  • So resulting string will be truncated once it reaches MAX_DATETIME_LEN characters.
  • Example : lr_save_datetime("Tomorrow is %B %d %Y", DATE_NOW + ONE_DAY, "next");

lr _advance_param :

  • lr_advance_param function causes the script to use the next available value of the parameter.
  • But if you are running multiple iterations, you can specify in the parameter properties to advance automatically to the next value for each iteration.
  • So use this function within an iteration to advance to the next value.
  • Therefore the function is not recorded—you insert it manually into your script.
  • Example : lr_advance_param("Param1");

lr _decrypt :

  • lr_decrypt function unmasks an encoded string. This function is generated during recording to encode passwords.
  • VuGen records the actual password but displays an encoded version of the password within the lr_decrypt function.
  • Example :  txtPassword = lr.decrypt("38620da61ca1093e7aa7ec");

lr_eval_string_ext :

  • lr_eval_string_ext function evaluates in_str by replacing parameters with their string value.
  • It creates a buffer containing the expanded string and sets out_str to point to that buffer.
  • But also assigns the length of the buffer to out_len. Use this function in conjunction with lr_eval_string_ext_free in preference to lr_eval_string when evaluating strings in a loop.
  • Using lr_eval_string in a loop uses more memory.
  • Example : lr_eval_string_ext ("{Param1}", 8, &newParam,  &prmLen, 0, 0,-1);

lr_eval_string_ext_free :

  • lr_eval_string_ext_free function frees the memory allocated by lr_eval_string_ext.
  • Example : lr_eval_string_ext ("{Param1}", 8, &newParam, &prmLen, 0, 0,-1);

lr_save_searched_string :

  • lr_save_searched_string function searches for string search_string inside string or character array buffer, and finds the nth occurrence of search_string, where n is occurrence plus 1.
  • So the sub-string to be saved starts at offset after the end of the nth occurrence of search_string, and has length string_len.
  • Example : lr_save_searched_string(data_1, olen, 0, "SCertRep", 9, 16, "cert1");

Click Here to see all the message function present in loadrunner.

One thought on “String Functions Present in Loadrunner

Leave a Reply

Your email address will not be published. Required fields are marked *