lr_paramarr_idx
char * lr_paramarr_idx( const char * paramArrayName, unsigned int index);
| Alphabetical Listing - C Language Utility Functions |
Arguments
| Name | Comments |
|---|---|
| paramArrayName | The name of the parameter array from which to return the value. |
| index | The one-based position of the parameter in the array. |
lr_paramarr_idx retrieves a string containing the value of the parameter at the specified position in a parameter array. If the parameter does not exist, the return value is the concatenation of "{", paramArrayName, "_", index, and "}", for example, "{myParam_4}".
Return Values
A pointer to a string buffer containing the value. On error, it returns NULL.
Note: This function allocates memory internally. The memory is automatically freed at the end of each iteration.
Parameterization
Standard parameterization is not available for this function.
Example
This example shows how to get the last value from a parameter array.
int arrSize;
int ord;
char * FlightVal;
web_reg_save_param("outFlightVal",
"LB=outboundFlight value=", "RB=>",
"ORD=ALL",
"SaveLen=18",
LAST );
web_submit_form("reservations.pl",
"Snapshot=t4.inf",
ITEMDATA,
"Name=depart", "Value=London", ENDITEM,
"Name=departDate", "Value=08/16/2015", ENDITEM,
"Name=arrive", "Value=New York", ENDITEM,
"Name=returnDate", "Value=08/16/2015", 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 ); Example: The result of the web_reg_save_param having been called before the web_submit_form is:
Notify: Saving Parameter "outFlightVal_1 = 230;378;08/16/2015"
Notify: Saving Parameter "outFlightVal_2 = 231;337;08/16/2015"
Notify: Saving Parameter "outFlightVal_3 = 232;357;08/16/2015"
Notify: Saving Parameter "outFlightVal_4 = 233;309;08/16/2015"
Notify: Saving Parameter "outFlightVal_count = 4" arrSize = lr_paramarr_len("outFlightVal");
FlightVal = lr_paramarr_idx("outFlightVal", arrSize);
Example: Output: FlightVal contains the value "233;309;08/16/2015".
// Submit a unique web request for each FlightVal in the Parameter array
for (ord=1; ord <= arrSize; ++ord) {
lr_save_string (lr_paramarr_idx("outFlightVal", ord), "flighVal");
web_url("reservations.lookup",
"URL=http://{host}/reservations/lookup?resvKey={flighVal}",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Mode=HTML",
LAST);
}
Example:
Requests will be made to:
http://{host}/reservations/lookup?resvKey=230;378;08/16/2015
http://{host}/reservations/lookup?resvKey=231;337;08/16/2015
http://{host}/reservations/lookup?resvKey=232;357;08/16/2015
http://{host}/reservations/lookup?resvKey=233;309;08/16/2015

