[Go] web_reg_save_param the array to be processed

Source: Internet
Author: User
Tags ord sprintf

Method One:

function (Sprintf,web_reg_save_param), where the red font is the most important in this document
#include "web_api.h"

Action ()
{
int i,iloop;
Char idparam[200];
Char idvalue[200];
...
Web_reg_save_param ("Topicarray", "Lb=topic_", "rb=.html", "notfound=warning", "Search=body", "Ord=all", last);
Note Ord=all
Web_url ("Access specified XXX",
"Url= Specifies the page to visit",
"Resource=0",
"Reccontenttype=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=http",
last);


for (i =1; i < atoi (lr_eval_string ("{topicarray_count}")) +1; i++) {


    sprintf (Idparam, "{topicarray_%d}", i);
    sprintf (idvalue, "%s", Lr_eval_string (Idparam));
    lr_save_string (idvalue, "TopicID"); //This is also a more useful function, put parameters, subsequent calls are relatively simple,
    Lr_message ("The value argument is:%s", lr_eval_string ("{ TopicID} "));


for (iloop = 0; Iloop < 5; iloop++) {
Web_submit_data ("Add_reply.do",
"Action=xxxxxxxxxxxx.do",
"Method=post",
"Reccontenttype=text/html",
"Referer=xxxxxxx_{topicid}.html",
"Mode=http",
ItemData,
"Name=allow_guest", "Value=on", Enditem,
"Name=url", "value=xxxxxxxxx{topicid}.html", Enditem,
"Name=username", "value=2007", Enditem,
"Name=title", "Value=null", Enditem,
"Name=content", "Value={topicid}", Enditem,
"Name=aaaa", "value=aaa", Enditem,
last);
}
}

Method Two:

How do I save multiple parameters using the Web_reg_save_param method?

In the Web_reg_save_param method, you can save multiple parameters if the parameter section indicates "Ord=all". For example "web_reg_save_param (" Flight_num "," Lb=<input type=/"checkbox/" name=/"", "rb=/" value=/"on/" > "," ORD=ALL ", last)", will be based on the actual situation to find eligible content, and then save the results found in the parameters flight_num_1,flight_num_2,flight_num_3 、...... In If you want to use these parameters, you can do so with arrays.

The following example shows how to save the found ticket to an array in the booking procedure, and then use the Loop statement to generate the parameter name and save it in the array. After you get the list of parameters, you can then do other things, such as deleting tickets.

Action ()

{int i;

int count;

Char param[10][20];

Web_reg_save_param ("Flight_num", "Lb=<input type=/" checkbox/"name=/" "," rb=/"value=/" on/">", "ORD=ALL", last) ;

Web_url ("Com.mercurytours.servlet.IteneraryServlet",

"Url=http://localhost/servlets/com.mercurytours.servlet.iteneraryservlet",

"Targetframe=",

"Resource=0",

"Reccontenttype=text/html",

"Referer=http://localhost/servlets/com.mercurytours.servlet.reservationservlet",

"Snapshot=t3.inf",

"Mode=html",

last);

Count=atoi (Lr_eval_string ("{flight_num_count}"));

lr_error_message (" number of tickets booked:%d", count);

for (i=1;i<=count;i++) {

sprintf (Param[i], "{flight_num_%d}", i);// The parameter name is stored in the array

Lr_error_message (Param[i]);

}

for (i=1;i<=count;i++) {

lr_error_message (lr_eval_string (Param[i]));// Use parameters

}

return 0;

}

[Go] web_reg_save_param processing of the resulting array

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.