Okay, this is a bit of a tease because I haven’t actually written this function, but it would be nice if someone out there would (maybe it will be me when I get some more free time).

web_reg_save_param() is a useful little function for easily extracting text from the last HTTP response received by the virtual user. You specify left and right boundaries, the occurrence of the text you want to find and a large number of other options which, admittedly, don’t give you the power of regular expressions but are a lot easier to use.

The only problem is that once you’ve got a piece of text from the web page (or some other source), you can’t use this function to help with further manipulations of the text. The closest equivalent function is lr_save_searched_string(), which is useful, but only allows you to specify a left boundary and the number of characters to save. To get the equivalent of web_reg_save_param() requires writing string manipulation code using the standard C libraries which, we all know, some people find a little difficult.

It would be nice to have a function that was the equivalent of web_reg_save_param(), but that you could pass an arbitrary string to. Various people have written functions that implement a small sub-set of the required functionality (like returning text between boundaries), but I have never seen anything which is even close being feature-complete; besides, code in Mercury’s User Contributed Knowledge Base is notoriously buggy.

A good implementation of this function – let’s call it lr_reg_save_param() – might have the following attributes…

  • Would accept the same arguments as web_reg_save_param(), except with an additional argument for the input string.
    int lr_reg_save_param (char* InputString, const char *ParamName, <list of Attributes>, LAST);
  • Would work in exactly the same way as web_reg_save_param() – I don’t want to have to learn how to use another function.
  • Would be threadsafe – users shouldn’t have to chase down this type of bug.
  • Would not create any LoadRunner parameters except for the parameter name specified – this prevents any problems when users inadvertently have a parameter name that is the same as one that is used internally by the function.
  • Would be well-tested and bug-free.

 

Published On: November 6, 2005Tags: ,

8 Comments

  1. Robin November 8, 2005 at 3:50 am

    “is a useful little function for easily extracting text from the last HTTP response ”
    As web_reg_save_param() is predeclared, wouldn’t it be more accurate to say ‘from the *next* HTTP response’ ?

  2. Chris Meisenzahl November 8, 2005 at 4:30 am

    Very helpful, thanks. I’ve been meaning to tinker with this functionality but never got to it.

    Chris

  3. chandru February 16, 2006 at 5:09 pm

    It is a useful function.

    But if there is any function to extract the data from a string which is extrcted from the page like the following, then it would really very gr8.

    1. (LB)(‘string1′,’string2′,’string3′,’string4’)(RB) from this –> (‘string1′,’string2′,’string3′,’string4’) this can be extracted very easily.
    2. But if want to use string1 string2 string3 string4 in 4 diff variables then i have to use strtok with the delimiters “‘,”.
    3. but problem will arise when the string1 or string2 or string3 or string4 contains the anyone delimiter (‘ or ,).
    4. Instead if there is any function like from which we can give a string (‘,’) as delimiter in loadrunner, then it would really very helpful.
    5. like in java,string.split.

    What do u say? Or is there any functions already available in loadrunner. ( I accept that we can write our own functions.)

    Chandru

  4. Linden November 30, 2007 at 11:22 am

    “3. but problem will arise when the string1 or string2 or string3 or string4 contains the anyone delimiter (’ or ,).”

    If you are extracting such comma-seperated values (csv) from the served HTML AND the values contain any commas then it is likely the developers have experienced the same problem you face – either the seperating commas fall after a certain number of characters (i.e. fixed character length values) [solution is to extract based on character length] or known values are found within the list (string match) [solution is to use any known values found to be existing in the csv]. So generally you should be safe to use strtok.

    I do agree though, use of unusual characters (or even use of extremely unusual sequences of unusual characters) is a more robust means of seperating values.

  5. AJ January 25, 2008 at 8:02 pm

    How about this. Most of you would have never used the little known attribute named Search when using web_reg_save_param() calls.

    [Search: The scope of the search—where to search for the delimited data. The possible values are Headers (Search only the headers), Body (search only body data, not headers), Noresource (search only the HTML body, excluding all headers and resources), or ALL (search body , headers, and resources). The default value is ALL. This attribute is optional.]

    This is an insanely restrictive use of a highly smart functionallity. I have written a function that would let the user to search for delimited data within another delimited data, much better than normal search options – header, body and the rest.
    Basically this is like adding another LB and RB for the search attribute. 🙂

    • Greg March 19, 2011 at 12:42 am

      AJ, any chance you would share that little search function?

  6. kelendral July 22, 2009 at 6:15 am

    I was looking for just such a thing. I have a website that returns a single huge string for all the tabs and the menu items under those tabs. With web_reg_save_param I am able to save the portion of the string related to each tab. However, I am not then able to pass that string along to be parsed out so I can retrieve the individual elements for the menu items under those tabs. It is driving me insane.

  7. deepak March 15, 2010 at 8:51 pm

    Can you explain more detail about Ord(Ordinal). I am confused, in few sites Ord is not mandatory value. But when i remove the Ord, i am getting error. Also when i do auto correlation value showing for Ord is 2. If i change the value for Ord to some other value say All or 1,3 etc, i am getting error. Also could be explain more about left and right boundaries. Please help me to understand better

Comments are closed.