web_reg_save_param函数英文实例

本文涉及的产品
网络型负载均衡 NLB,每月750个小时 15LCU
应用型负载均衡 ALB,每月750个小时 15LCU
传统型负载均衡 CLB,每月750个小时 15LCU
简介:

Example: web_reg_save_param

Example 1

In the Mercury Tours sample program, the server response to the  web_submit_form call below contains the following radio button options:
<tr bgcolor=#66cccc><th>Flight<th>Departure time<th>Cost
<tr bgcolor=#66CCff><td align=center><input type = radio name= outboundFlight value=230;378;11/20/2003 checked >Blue Sky Air 230<td align=center>8am<td align=center>$ 378
<tr bgcolor=#eeeeee><td align=center><input type = radio name= outboundFlight value=231;337;11/20/2003>Blue Sky Air 231<td align=center>1pm<td align=center>$ 337
and so on.
To submit a reservation, the  outboundFlight value is required.
Simple case
To reserve the default flight, save the "checked" value, and pass it to web_submit_form. The html segment for the default value is:
name= outboundFlight value=230;378;11/20/2003 checked >
/*This web_reg_save_param call applies to the following action function: web_submit_form. */
        web_reg_save_param("outFlightVal",
       "LB=outboundFlight value=", "RB= checked >", 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:
Action.c(15): Notify: Saving Parameter "outFlightVal = 230;378;11/20/2003"
*/
// Now use the saved outFlightVal
       web_submit_form("reservations.pl_2",
              "Snapshot=t5.inf",
              ITEMDATA,
              "Name=outboundFlight", "Value={ outFlightVal}", ENDITEM,
              "Name=reserveFlights.x", "Value=92", ENDITEM,
              "Name=reserveFlights.y", "Value=10", ENDITEM,
              LAST);
/*
Action.c(34): Notify: Parameter Substitution: parameter "outFlightVal" = "230;378;11/20/2003" */
Case requiring handling arrays
If you want to test the last option, save all the matches and then handle the array.
This example shows the use of  web_reg_save_param with " ORD=ALL" to get an array of parameters. The last item in the array is then used to correlate a  web_submit_form call.
char outFlightParam[50]; // The name of the parameter for correlation
char outFlightParamVal[50]; // The formatted value of outFlightParam
/*
This web_reg_save_param call applies to the following action function, web_submit_form. Because of the "ORD=ALL" argument, it saves all the values that have the given left and right boundaries to an array of parameters.
The SaveLen argument is used to restrict the length to 18 characters because the default value is "230;378;11/20/2003 checked >". We restrict the length so as not to capture the " checked ".
*/
        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"
The next problem is to get the highest array element, identified with the parameter  outFlightVal_count. This parameter is automatically created by the script recorder. You do not have to enter anything in the script.
*/
/* Get the name of the parameter, in this case "outFlightVal_4".
Put it in brackets so it can be an input to an  lr_eval_string call.
Note that the brackets in the second argument to  sprintf are not indicating a script parameter to  sprintf. They are string literals that will be part of outFlightParam after the call.
In the second call to  sprintf, those brackets indicate a parameter to  lr_eval_string.
*/
       sprintf(outFlightParam, " {outFlightVal_%s }",
              lr_eval_string("{outFlightVal_count}"));
/* outFlightParam is now "{outFlightVal_4}" */
       /* Now get the "Value" argument for web_submit_form, in the
              format "Value=xxxx")
       */
       sprintf(outFlightParamVal, "Value=%s",
              lr_eval_string(outFlightParam));
       lr_message("The value argument is : %s", outFlightParamVal);
       // The value argument is : Value=233;309;11/20/2003
       /* Now the string outFlightParamVal can be passed
              to web_submit_form */
       web_submit_form("reservations.pl_2",
              "Snapshot=t5.inf",
              ITEMDATA,
              "Name=outboundFlight", outFlightParamVal, ENDITEM,
              "Name=reserveFlights.x", "Value=92", ENDITEM,
              "Name=reserveFlights.y", "Value=10", ENDITEM,
              LAST);

Example 2

The following example uses BIN type boundaries. The left boundary is composed of  3F and  DD. The right boundary is composed of  CC and  b.
web_reg_save_param("p", "LB/BIN=\\x3F\\xDD", "RB/BIN=\\xCCb", LAST);

Example 3

The following example specifies an offset and length. The boundaries for the HTML string "Astra on TESTSERVER", are "Astra  " (note the space which follows the word) and "TestServer" This should return "on" but since the offset is 1 (i.e. start at the second character) and the length of data to save is 1, then the string saved to  TestParam is "n".
web_reg_save_param("Param1", "LB=Astra ", "RB= TESTSERVER",
       "SaveOffset=1", "SaveLen=1", LAST);

Example 4

The following example shows the use of escaping in the C language when the boundaries contain special characters.
The following HTML segment contains new line characters (paragraph markers) after each "<strong>" and quote marks around each class name. We want to save "Georgiana Darcy" to parameter "UserName". The segment containing the new line and quotes has to be included in the left boundary because "Name:", which precedes the segment, is required for the occurrence to be unique. The ORD attribute cannot be used in this case because the length of the list preceding the relevant element varies.
<span class="surveyQuestionReview"><strong> UserID:</strong></span><strong>
    </strong> <span class="surveyAnswerReview">Revere18041775</span> <br>
<span class="surveyQuestionReview"><strong>  Name:</strong></span><strong>
    </strong> <span class="surveyAnswerReview">Georgiana Darcy</span> <br>
<span class="surveyQuestionReview"><strong> Company:</strong></span><strong>
    </strong> <span class="surveyAnswerReview">Pride and Prejudice</span> <br>
The function is:
web_reg_save_param("UserName",
"LB=Name:</strong></span><strong>  \n    </strong> <span class= \"surveyAnswerReview \">",
              "RB=</span> <br>",
              LAST);
Note the  \n for the new line character, and that the quote characters need to be escaped:  \".




本文转自 fish_yy 51CTO博客,原文链接:http://blog.51cto.com/tester2test/139559,如需转载请自行联系原作者
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
目录
相关文章
|
JSON JavaScript Go
Go 语言学习指南:变量、循环、函数、数据类型、Web 框架等全面解析
掌握 Go 语言的常见概念,如变量、循环、条件语句、函数、数据类型等等。深入了解 Go 基础知识的好起点是查阅 Go 官方文档
1088 2
|
数据库 开发者 Python
实战指南:用Python协程与异步函数优化高性能Web应用
在快速发展的Web开发领域,高性能与高效响应是衡量应用质量的重要标准。随着Python在Web开发中的广泛应用,如何利用Python的协程(Coroutine)与异步函数(Async Functions)特性来优化Web应用的性能,成为了许多开发者关注的焦点。本文将从实战角度出发,通过具体案例展示如何运用这些技术来提升Web应用的响应速度和吞吐量。
149 1
|
数据库 开发者 Python
实战指南:用Python协程与异步函数优化高性能Web应用
【7月更文挑战第15天】Python的协程与异步函数优化Web性能,通过非阻塞I/O提升并发处理能力。使用aiohttp库构建异步服务器,示例代码展示如何处理GET请求。异步处理减少资源消耗,提高响应速度和吞吐量,适用于高并发场景。掌握这项技术对提升Web应用性能至关重要。
280 10
|
存储 Linux 网络安全
【Azure 应用服务】App Service For Linux 如何在 Web 应用实例上住抓取网络日志
【Azure 应用服务】App Service For Linux 如何在 Web 应用实例上住抓取网络日志
127 0
|
Java Serverless 应用服务中间件
Serverless 应用引擎产品使用合集之Web函数启动的Spring Boot项目可以通过什么方式配置Nginx
阿里云Serverless 应用引擎(SAE)提供了完整的微服务应用生命周期管理能力,包括应用部署、服务治理、开发运维、资源管理等功能,并通过扩展功能支持多环境管理、API Gateway、事件驱动等高级应用场景,帮助企业快速构建、部署、运维和扩展微服务架构,实现Serverless化的应用部署与运维模式。以下是对SAE产品使用合集的概述,包括应用管理、服务治理、开发运维、资源管理等方面。
|
JavaScript 前端开发 索引
【Web 前端】jQuery 里的 each() 是什么函数?你是如何使用它的?
【5月更文挑战第2天】【Web 前端】jQuery 里的 each() 是什么函数?你是如何使用它的?
js中如何使用工厂方式和构造函数创建对象,web开发项目实例
js中如何使用工厂方式和构造函数创建对象,web开发项目实例
|
前端开发 JavaScript UED
【Web 前端】异步函数
【5月更文挑战第1天】【Web 前端】异步函数
|
自然语言处理 前端开发
【Web 前端】es6 中的箭头函数?
【5月更文挑战第1天】【Web 前端】es6 中的箭头函数?
|
前端开发 JavaScript
【Web 前端】$(document).ready() 是个什么函数?为什么要用它?
【5月更文挑战第2天】【Web 前端】$(document).ready() 是个什么函数?为什么要用它?