Share this page

# web_reg_save_param

Registers a request to save dynamic data information to a parameter.

The C language version of this function is deprecated: In C, use web_reg_save_param_ex or web_reg_save_param_xpath.

## Java Language

    int object.reg_save_param( String ParamName, String[] attributeList);

Correlation Functions for Java | Java Syntax

Argument | Description
--- | ---
object | An expression evaluating to an object of type WebApi. Usually web for Java. See also Function and Constant Prefixes.
ParamName | A null–terminated string indicating the name of the parameter to create.
List of Attributes | For details of each attribute, see List of Attributes. Attribute value strings are not case–sensitive. For example, "Search=all" is the same as "Search=All.
LAST | A marker that indicates the end of the argument list.

## Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

## Parameterization

The following argument(s) can be parameterized using standard parameterization: ParamName, List of Attributes

## General Information

web_reg_save_param registers a request to find and save a text string within the server response to the next action function. The search does not to apply values returned as a result of calls to asynchronous or cross-step functions.

web_reg_save_param is only recorded when correlation during recording is enabled (see VuGen's Recording Options). VuGen must be in either URL–based recording mode, or in HTML–based recording mode with the A script containing explicit URLs only option checked (see VuGen's Recording Options).

This function registers a request to retrieve dynamic information from the downloaded page, and save it to a parameter. For correlation, enclose the parameter in braces (e.g., "{param1}") in ensuing function calls which use the dynamic data. See also Correlating Statements.

The request registered by web_reg_save_param looks for the characters between (but not including) the specified boundaries and saves the information that begins at the byte after the left boundary and ends at the byte before the right boundary.

If you expect leading and trailing spaces around the string and you do not want them in the parameter, add a space at the end of the left boundary, and at the beginning of the right boundary. For example, if the web page contains the string, "Where and when do you want to travel?", the call:

web_reg_save_param("When_Txt", "LB=Where and ", "RB= do", LAST );

with a space after "and" and before "do", will result in "when" as the value of When_Txt. However,

web_reg_save_param("When_Txt", "LB=Where and", "RB=do", LAST );

without the spaces, will result in a value of " when ".

Embedded boundary characters are not supported. web_reg_save_param results in a simple search for the next occurrence after the most recent left boundary. For example, if you have defined the left boundary as the character `{` and the right boundary as the character `}', then with the following buffer c issaved:

Example: {a{b{c}

The left and right boundaries have been located. Since embedded boundaries are not supported, the `}' is matched to the most recent `{` appearing just before the c. The ORD attribute is 1. There is only one matching instance.

The web_reg_save_param function also supports array type parameters. When you specify ORD=All, all the occurrences of the match are saved in an array. Each element of the array is represented by the ParamName_index. In the following example, the parameter name is A:

web_reg_save_param("A", "LB/ic=<a href=", "RB=\'>", "Ord=All", LAST );

The first match is saved as A_1, the second match is saved as A_2, and so forth. You can retrieve the total number of matches by using the following term: ParamName_count. For example, to retrieve the total number of matches saved to the parameter array, use:

`TotalNumberOfMatches=atoi(lr_eval_string("{A_count}"));`

The following table indicates how to use the boundary parameters to save portions of the parameter string:

Portion of string to save to parameter | LB | RB
the entire string | empty | empty
a string delimited by boundaries | boundary | boundary
the beginning of a string until the first right boundary | empty | boundary
the last left boundary until the end | boundary | empty

This function is supported for all web scripts.

## List of Attributes

- Convert: The possible values are:
  HTML_TO_URL: convert HTML–encoded data to a URL–encoded data format
  HTML_TO_TEXT: convert HTML–encoded data to plain text format
  This attribute is optional.

- IgnoreRedirections: If "IgnoreRedirections=Yes" is specified and the server response is redirection information (HTTP status code 300-303, 307), the response is not searched. Instead, after receiving a redirection response, the GET request is sent to the redirected location and the search is performed on the response from that location.
  This attribute is optional. The default is "IgnoreRedirections=No".

- LB: The left boundary of the parameter or the dynamic data. If you do not specify an LB value, it uses all of the characters from the beginning of the data as a boundary. Boundary parameters are case–sensitive and do not support regular expressions. To further customize the search text, use one or more Text Flags. This attribute is required. See the Boundary arguments section.

- NOTFOUND: The handling option when a boundary is not found and an empty string is generated.
  `"Notfound=error"`, the default value, causes an error to be raised when a boundary is not found.
  `"Notfound=warning"`. The `"warning"` option is ideal if you want to see if the string was found, but you do not want the script to fail.
  Note: If Continue on Error is enabled for the script, then even when NOTFOUND is set to `"error"`, the script continues when the boundary is not found, but an error message is written to the Extended log file.
  This attribute is optional.

- ORD:Example of Parameter Arrays.
  This attribute is optional.
  Note: The use of Instance instead of ORD is supported for backward compatibility, but deprecated.

- RB: The right boundary of the parameter or the dynamic data. If you do not specify an RB value, it uses all of the characters until the end of the data as a boundary. Boundary parameters are case–sensitive and do not support regular expressions. To further customize the search text, use one or more Text Flags. This attribute is required. See the Boundary arguments section.

- RelFrameID: The hierarchy level of the HTML page relative to the requested URL. The possible values are ALL or a number. Click RelFrameID Attribute for a detailed description. This attribute is optional.
  Note: RelFrameID is not supported in GUI level scripts.

- SaveLen: The length of a sub–string of the found value, from the specified offset, to save to the parameter. This attribute is optional. The default is –1, indicating to save to the end of the string.

- SaveOffset: The offset of a sub–string of the found value, to save to the parameter. The offset value must be non–negative. The default is 0. This attribute is optional.

- 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.

## Example - C Language

In this example, web_reg_save_param saves a value from the response to a web_submit_form call. The value saved is used in a subsequent web_submit_form call. In the Web Tours program, the server response to the submit_form call below contains the following radio button options:

<tr bgcolor=#66cccc><th>Flight<th>Departure time<th>Cost

<tr bgcolor=#66CCff><td align=center>

<input type = radio name=outboundFlight value=230;378;11/20/2003 checked >Blue Sky Air 230<td align=center>8am

<td align=center>$ 378 <tr bgcolor=#eeeeee>

<td align=center><input type = radio name=outboundFlight value=231;337;11/20/2003>Blue Sky Air 231

<td align=center>1pm<td align=center>$ 337

...

To submit a reservation, the outboundFlight value is required. To reserve the default flight, save the "checked" value, and pass it to web_submit_form. The html segment for the default value is: name=outboundFlight value=230;378;11/20/2003 checked >

Copy code

    /*This web_reg_save_param call applies to the following action function: web_submit_form. */
        web_reg_save_param("outFlightVal",
        "LB=outboundFlight value=", "RB= checked >", LAST);
        web_submit_form("reservations.pl",
            "Snapshot=t4.inf",
            ITEMDATA,
            "Name=depart", "Value=London", ENDITEM,
            "Name=departDate", "Value=11/20/2003", ENDITEM,
            "Name=arrive", "Value=New York", ENDITEM,
            "Name=returnDate", "Value=11/21/2003", ENDITEM,
            "Name=numPassengers", "Value=1", ENDITEM,
            "Name=roundtrip", "Value=<OFF>", ENDITEM,
            "Name=seatPref", "Value=None", ENDITEM,
            "Name=seatType", "Value=Coach", ENDITEM,
            "Name=findFlights.x", "Value=83", ENDITEM,
            "Name=findFlights.y", "Value=16", ENDITEM,
            LAST);
    /* The result of the web_reg_save_param having been called before the web_submit_form is:
        Action.c(15): Notify: Saving Parameter "outFlightVal = 230;378;11/20/2003"*/
    // Now use the saved outFlightVal
        web_submit_form("reservations.pl_2",
            "Snapshot=t5.inf",
            ITEMDATA,
            "Name=outboundFlight", "Value={outFlightVal}", ENDITEM,
            "Name=reserveFlights.x", "Value=92", ENDITEM,
            "Name=reserveFlights.y", "Value=10", ENDITEM,
            LAST);

    /* Action.c(34): Notify: Parameter Substitution: parameter "outFlightVal" = "230;378;11/20/2003" */

## Examples - Java Language

### Example 1: Saving simple text strings

Copy code

    web.reg_save_param (""outFlightVal",
        new String []{
            "NOTFOUND=ERROR",
            "LB=outboundFlight value=",
            "RB=>" ,
            "LAST"} );

### Example 2: Saving text by using binary boundaries

The following example uses BIN type boundaries. The left boundary is composed of 3F and DD. The right boundary is composed of CC and b.

Copy code

    web.reg_save_param("p",
        new String []{
            "LB/BIN=\\x3F\\xDD", "RB/BIN=\\xCCb", "LAST"});

### Example 3: Saving text specified by an offset and length

The following example specifies an offset and length. The boundaries for the HTML string "Astra on TESTSERVER", are "Astra " (note the space which follows the word) and "TestServer". This should return "on" but since the offset is 1 (i.e., start at the second character) and the length of data to save is 1, then the string saved to TestParam is "n".

Copy code

    web.reg_save_param("Param1",
        new String []{
            "LB=Astra ", "RB= TESTSERVER",
            "SaveOffset=1", "SaveLen=1", "LAST"});

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: