城邦 发表于 2013-5-7 09:27:31

如何随机选取web_reg_save_param保存的函数

本帖最后由 thirfing 于 2013-5-7 16:25 编辑

Problem Description: How to randomly select parameters saved by web_reg_save_param

How to randomly select parameters saved by web_reg_save_param with the attribute ORD = ALL.






--------------------------------------------------------------------------------

Solution: Use custom C coding to randomly select parameters

You can randomly select parameters saved by web_reg_save_param with the attribute ORD = ALL by using custom C coding in your script.

EXAMPLE:

Action1()
{


char* temp,i;
int j;

//create a parameter with the desired boundaries
web_reg_save_param ("pram", "NOTFOUND=ERROR", "LB=left_b","RB=right_b" , "ORD=ALL", LAST );

//call to the URL
web_url("HomePage", "URL=<Your_URL>", LAST);

//get the total number of occurance captured
j = atoi(lr_eval_string("{pram_count}"));

//generate a random number between 1 to j
sprintf(&i, "%d", ( 1 + rand() % j));

//save the random number as a parameter - random_value
lr_save_string(&i, "random_value");

//get the value of parameter x (generated via random number )
temp = lr_eval_string(lr_eval_string("{pram_{random_value}}"));

//save the data as a parameter - random_param
lr_save_string(temp, "random_param");

//call a random URL
web_url("Example", "URL={random_param}", LAST);

return 0;
}

城邦 发表于 2013-5-8 09:51:12

抢个沙发先
页: [1]
查看完整版本: 如何随机选取web_reg_save_param保存的函数