Share this page

# web_reg_save_param_ex

Correlation Functions for C

Registers a request to save dynamic data located between specified boundaries. The data is saved to a parameter.

## C Language

    int web_reg_save_param_ex("ParamName=<output parameter name>", [LB[/IC][BIN]=<value>,] [RB[/IC][BIN]=<value>, ] <list of attributes>, SEARCH FILTERS, LAST );

Argument | Description
--- | ---
The left boundary of the dynamic data. See Left Boundary.
RB | The right boundary of the dynamic data See Right Boundary.
List of Attributes | For details of each attribute, see Attributes for Save Parameter Registration Functions. Attribute value strings (e.g., "NotFound=warning") are not case-sensitive. See also Restrictions.
SEARCH FILTERS | Specifies the sections of the buffer to search for the data in. See Search Filters for Save Parameter Registration Functions and Restrictions.
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 values of keyword-value pairs can be parameterized. For example, "ALT={altParam}".

## General Information

web_reg_save_param_ex registers a request to find and save dynamic data within the server response to the next action function. The data to be saved is between the specified left and right boundaries. The search does not to apply values returned as a result of calls to asynchronous or cross-step functions.

The dynamic data found is saved to a parameter. For correlation, enclose the parameter name in braces (e.g., "{param1}") in ensuing function calls that use the dynamic data. See also Correlating Statements.

The request registered by web_reg_save_param_ex looks for the data 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_ex("ParamName=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_ex("ParamName=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_ex does 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 is saved:

`{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_ex function also supports array type parameters. When you specify Ordinal=All, all the occurrences of the match are saved in an array. Each element of the array is represented by the ParamName_index. See web_reg_save_param_ex.

In the following example, the parameter name is A:

web_reg_save_param_ex("ParamName=A", "LB/ic=<a href=", "RB=\'>", "Ordinal=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
From the last LB to the RB | boundary | boundary
From the beginning of a string until the first right boundary | empty | boundary
From the last left boundary until the end | boundary | empty

If either boundary is empty, do not specify an Ordinal attribute.

web_reg_save_param_ex replaces the deprecated web_reg_save_param. web_reg_save_param has a CONVERT attribute for changing from HTML format to URL or Text formats. This attribute is not available with web_reg_save_param_ex. If you require the functionality, use web_convert_param to format the parameter after it is saved by web_reg_save_param_ex .

To capture a value from a random index, specify Ordinal=RANDOM. Only one value from within the boundary is returned.

web_reg_save_param_ex is not recorded. You can add it manually to a script.

web_reg_save_param_ex is supported for all web scripts.

## Left Boundary

If you do not specify an LB value, or if you set the value to an empty string, web_reg_save_param_ex uses the beginning of the data as a boundary. All of the characters from the beginning to the right boundary are saved. For more details on specifying a boundary, see the Boundary arguments section.

The LB argument can take Boundary Qualifiers.

## Right Boundary

The right boundary of the parameter or the dynamic data. If you do not specify an RB value, or if you set the value to an empty string, web_reg_save_param_ex saves all of the characters from the left boundary until the end of the data. For more details on specifying a boundary, see the Boundary arguments section.

The RB argument can take Boundary Qualifiers.

## Boundary Qualifiers

The LB and LR arguments to web_reg_save_param_ex can take the following qualifiers:

/IC - case insensitive. The boundary matches even if the case of the boundary value is not the same as the case in the string in the buffer.
/BIN - The value is escaped binary code. See Binary Code.

In release 11.00, the /RE qualifier was supported. This support is discontinued because fuller regular expression functionality is now provided by web_reg_save_param_regexp.

## Restrictions

No searches are performed in data downloaded asynchronously.

If the DFES argument is specified and the Scope argument is not specified, the search Scope is `Body` (instead of the default, `ALL`).

If both the DFES and the Scope arguments are specified and Scope is set to `ALL`, the DFES argument is ignored.

If the HeaderNames argument is specified and the Scope is not `Headers`, the HeaderNames argument is ignored.

If the RelFrameID=ALL argument is specified, the Ordinal argument must be omitted or set to `ALL`.

For more information on the DFES argument, see Attributes for Save Parameter Registration Functions.

For more information on the HeaderNames and Scope arguments, see Search Filters for Save Parameter Registration Functions

For more information on the RelFrameID argument, see Search Filters for Save Parameter Registration Functions and RelFrameID Attribute.

## Example 1

This example shows the use of web_reg_save_param_ex to save all of the strings between `LL` and `RR` in the body of a response.

Copy code

    Action()
    {
    char arrayParamName[50];
    int elemCnt;
    int x;
        lr_save_string( "HTTP%2F1%2E1%20301%20Moved%20Permanently%0A%0D"
        "Content%2DType%3A%20text%2Fhtml%0A%0D"
        "Date%3A%20Sun%2C%2014%20Feb%202010%2011%3A15%3A34%20GMT%0A%0D"
        "%0A%0D"
        "aaLLb%20bLLc%20%2E%2ecRRddRReeRRffLLggsadfsdfsdfRRhhRRiiLLj%20%2d%2DjRRkkLLmmLLnnRRoooRRpppLLqqq%0A%0D",
            "inParam" );

    web_reg_save_param_ex(
        "ParamName=newParam",
        "LB/IC=ll",
        "RB/IC=RR",
        "Ordinal=all",
        "SaveLen=-1",
        "DFEs=UrlEncoding",
        SEARCH_FILTERS,
            "Scope=body",
        LAST);

    web_submit_data("echo.asp_2",
        "Action=http://localhost/cgi-bin/echo.asp",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=text/html",
        "Referer=http://localhost/cgi_examples/echo_asp.html",
        "Snapshot=t4.inf",
        "Mode=HTML",
        ITEMDATA,
            "Name=code", "Value={inParam}", ENDITEM,
        LAST);
    /*     Getting individual elements from a parameter array.
        Since the parameter created by web_reg_save_param_ex
        is called "newParam", the number of elements
        is saved in parameter "newParam_count".
        The array elements are parameters "newParam_1",
        "newParam_2", ... "newParam_n". */
    elemCnt = atoi(lr_eval_string("{newParam_count}"));
    lr_output_message("Number of items found = %d",elemCnt);
    for (x=1;x<=elemCnt;x++) {
        sprintf(arrayParamName, "{newParam_%d}", x);
        lr_output_message ("%s: %s",        arrayParamName,        lr_eval_string(arrayParamName));
    }
        return 0;
    }

Example: Action.c(41): Number of items found = 4
Action.c(45): {newParam_1}: c ..c
Action.c(45): {newParam_2}: ggsadfsdfsdf
Action.c(45): {newParam_3}: j --j
Action.c(45): {newParam_4}: nn

## Example 2

This example shows the use of web_reg_save_param_ex to save all of the strings between `LL` and `RR` in the body of a response.

Copy code

    Action()
    {
    char arrayParamName[50];
    int elemCnt;
    int x;
        lr_save_string( "HTTP%2F1%2E1%20301%20Moved%20Permanently%0A%0D"
        "Content%2DType%3A%20text%2Fhtml%0A%0D"
        "Date%3A%20Sun%2C%2014%20Feb%202010%2011%3A15%3A34%20GMT%0A%0D"
        "%0A%0D"
        "aaLLb%20bLLc%20%2E%2ecRRddRReeRRffLLggsadfsdfsdfRRhhRRiiLLj%20%2d%2DjRRkkLLmmLLnnRRoooRRpppLLqqq%0A%0D",
            "inParam" );

    web_reg_save_param_ex(
        "ParamName=newParam",
        "LB/IC=ll",
        "RB/IC=RR",
        "Ordinal=all",
        "SaveLen=-1",
        "DFEs=UrlEncoding",
        SEARCH_FILTERS,
            "Scope=body",
        LAST);

    web_submit_data("echo.asp_2",
        "Action=http://localhost/cgi-bin/echo.asp",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=text/html",
        "Referer=http://localhost/cgi_examples/echo_asp.html",
        "Snapshot=t4.inf",
        "Mode=HTML",
        ITEMDATA,
            "Name=code", "Value={inParam}", ENDITEM,
        LAST);
    /*     Getting individual elements from a parameter array.
        Since the parameter created by web_reg_save_param_ex
        is called "newParam", the number of elements
        is saved in parameter "newParam_count".
        The array elements are parameters "newParam_1",
        "newParam_2", ... "newParam_n". */
    elemCnt = atoi(lr_eval_string("{newParam_count}"));
    lr_output_message("Number of items found = %d",elemCnt);
    for (x=1;x<=elemCnt;x++) {
        sprintf(arrayParamName, "{newParam_%d}", x);
        lr_output_message ("%s: %s",        arrayParamName,        lr_eval_string(arrayParamName));
    }
        return 0;
    }

Example: Action.c(41): Number of items found = 4
Action.c(45): {newParam_1}: c ..c
Action.c(45): {newParam_2}: ggsadfsdfsdf
Action.c(45): {newParam_3}: j --j
Action.c(45): {newParam_4}: nn

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: