You can find certain cases in your testing where you need to correlate parameter values in arrays. i.e. When server returns a list of values or a table
If we want only first value from this parameter array then there is no need to go for array and no need to use "ORD=ALL", we can get the value by providing boundaries and "ORD=1" but if we have certain cases where we not to take value from any specified location within array (i.e. Third value from the array). Also we might have top choose ant random value from the array.
These are some inbuilt function comes with LR which can be used with array variables and can fulfill our need.
int arrSize;
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=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:
Notify: Saving Parameter "outFlightVal_1 = 230;378;11/20/2003"
Notify: Saving Parameter "outFlightVal_2 = 231;337;11/20/2003"
Notify: Saving Parameter "outFlightVal_3 = 232;357;11/20/2003"
Notify: Saving Parameter "outFlightVal_4 = 233;309;11/20/2003"
Notify: Saving Parameter "outFlightVal_count = 4"
arrSize = lr_paramarr_len("outFlightVal");
FlightVal = lr_paramarr_idx("outFlightVal", arrSize);
FlightVal = lr_paramarr_random("outFlightVal");
lr_paramarr_len is used to get the length of the parameter array.
lr_paramarr_idx is used to get the value from the specified location from array (in FlightVal = lr_paramarr_idx("outFlightVal", arrSize); We are taking last value from the parameter array and storing it into FlightVal )
lr_ paramarr_random is used to retrieve value from any random index of the array (FlightVal = lr_paramarr_random("outFlightVal"); This will retrieve value from any randon index of the array and will store this value in FlightVal )