Here I am giving the random function code. This code is very useful in selection of random number out of a pool. Ex selection of 1 value from drop down, click on a link out of 10 link etc..
web_reg_save_param("soc","LB=option value=\"","RB=\"","ORD=ALL",LAST);
TotalMatchesCount=atoi(lr_eval_string("{soc_count}"));
if(TotalMatchesCount>0)
{
srand(time(NULL));
random=rand()%TotalMatchesCount+1;
sprintf(sRandomURL,"{soc_%d}",random);
lr_save_string(lr_eval_string(sRandomURL),"soc_value");
lr_output_message("Parameter value = %s",lr_eval_string(sRandomURL));
lr_start_transaction("ABC");
-------------
Body=searchParamTxt=Search+Pol&gcDirectoryIn=First+name&pt1:r3:0:soc1={soc_value}
-------------
lr_end_transaction("ABC",LR_AUTO);
}
else
{
lr_output_message("%s","Not Found link");
}
Note: Suppose TotalMatchesCount is 5. Then random=rand()%TotalMatchesCount generates value between 0 to 4 so we add 1 so that it become 1 to 5. Now we can use soc_1..... soc_5.
web_reg_save_param("soc","LB=option value=\"","RB=\"","ORD=ALL",LAST);
TotalMatchesCount=atoi(lr_eval_string("{soc_count}"));
if(TotalMatchesCount>0)
{
srand(time(NULL));
random=rand()%TotalMatchesCount+1;
sprintf(sRandomURL,"{soc_%d}",random);
lr_save_string(lr_eval_string(sRandomURL),"soc_value");
lr_output_message("Parameter value = %s",lr_eval_string(sRandomURL));
lr_start_transaction("ABC");
-------------
Body=searchParamTxt=Search+Pol&gcDirectoryIn=First+name&pt1:r3:0:soc1={soc_value}
-------------
lr_end_transaction("ABC",LR_AUTO);
}
else
{
lr_output_message("%s","Not Found link");
}
Note: Suppose TotalMatchesCount is 5. Then random=rand()%TotalMatchesCount generates value between 0 to 4 so we add 1 so that it become 1 to 5. Now we can use soc_1..... soc_5.
No comments:
Post a Comment