lr_save_string和sprintf、lr_eval_string的使用
一、lr_save_string函数
1.该函数主要是将程序中的常量或变量保存为参数;
//将常量保存为参数
lr_save_string("777","page");
web_url(http://www.sina.com.cn/{page});
lr_eval_string("{page}"); //将变量保存为参数,tmp为变量
lr_save_string(tmp,"page");
web_url(http://www.sina.com.cn/{page});
lr_eval_string("{page}");
二、sprintf函数
定义函数 | int sprintf( char *str,const char * format,.........); |
函数说明 | sprintf()会根据参数format字符串来转换并格式化数据,然后将结果复制到参数str所指的字符串数组,直到出现字符串结束(’\0’)为止。关于参数format字符串的格式请参考printf()。 |
返回值 | 成功则返回参数str字符串长度,失败则返回-1,错误原因存于errno中。 |
附件说明 | 使用此函数得留意堆栈溢出,或改用snprintf()。 |
示例 | #include<stdio.h> main() { char * a=”This is string A!”; char buf[80]; sprintf(buf,”>>> %s<<<\n”,a); printf(“%s”.buf); } |
执行 | >>>This is string A!<<< |
常用该函数代替itoa,将整数格式化为字符串形式。
例如:
int page=0;
char page_ch[60];
page=page + 10;
sprintf(page_ch,"%d",page);
三、lr_eval_string函数
用于返回instring参数中的实际字符串值,可以使用该函数来查看参数化取值是否正确;
char *tmp="hello";
lr_save_string("777","page"); //将常量777保存为参数page
lr_output_message(lr_eval_string("{page}")); //获取并输出参数page的当前值
lr_save_string(tmp,"page"); //将变量保存为参数,tmp为变量 lr_output_message(lr_eval_string("{page}"));
脚本示例:
example:
int count;
web_reg_save_param("flight_num",
"LB=新",
"RB=闻",
"ORD=All",
LAST);
count=atoi(lr_eval_string("{flight_num_count}")); //sprintf The following example uses sprintf to write the name of a file to a string buffer,
filename. This name is made up of the word "log", an underscore, the value of i, and the
file suffix. example:
Action()
{
int index = 56;
char filename[64], *suffix = "txt"; sprintf(filename, "log_%d.%s", index, suffix);
lr_output_message("The new file name is %s", filename); return 0;
}
Output:
Action.c(9): The new file name is log_56.txt //
lr_save_string Saves a null-terminated string to a parameter. int lr_save_string (const char *param_value, const char *param_name); aram_value The value to assign to the parameter.
param_name The name of the parameter. The lr_save_string function assigns the specified null-terminated string to a parameter.
This function is useful in correlating queries. To determine the value of the parameter,
use the lr_eval_string function. example:
lr_save_string("777", "emp_id"); ///
#include "as_web.h" Action()
{ int i;
int count;
char param[10][20]; web_reg_save_param("flight_num",
"LB=新",
"RB=闻",
"ORD=All",
LAST); web_add_cookie("BAIDUID=643CC8042E92F7FB5EF83827498BDBDC:FG=1; DOMAIN=www.baidu.com"); web_add_cookie("BDSTAT=495409234680ac099258d109b3de9c82d158ccbf6f81800a19d8bc3eb035a10e;
DOMAIN=www.baidu.com"); web_add_header("Accept-Language",
"zh-cn"); web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST); count=atoi(lr_eval_string("{flight_num_count}"));
lr_error_message("已经数量:%d",count);
for(i=1;i<=count;i++)
{
sprintf(param[i],"{flight_num_%d}",count);
lr_error_message(param[i]);
}
for(i=1;i<count;i++)
{
lr_error_message(lr_eval_string(param[i]));
} return 0;
}
lr_save_string和sprintf、lr_eval_string的使用的更多相关文章
- 转:lr_eval_string,lr_save_string 和 sprintf 的使用
lr_eval_string,lr_save_string和 sprintf 函数使用介绍 一.lr_eval_string 使用介绍1.函数的主要作用:返回脚本中的一个参数当前的值,返回值类型:ch ...
- lr_save_string 和 sprintf 的使用
lr_save_string 和 sprintf 的使用 一.lr_save_string 使用介绍1.该函数主要是将程序中的常量或变量保存为lr中的参数.格式: //将常量保存为参数 lr_save ...
- LoadRunner lr_eval_string() 函数使用及LR中变量、参数的简单使用
lr_eval_string() 函数的主要作用:返回脚本中的一个参数当前的值, 返回值类型:char 一般多用在调试脚本时输出参数的值.具体用法如下:lr_output_message(" ...
- lr函数之lr_eval_string()函数的使用学习
lr_eval_string() 函数的主要作用:返回脚本中的一个参数当前的值(从参数中取得对应的值,并且转换为一个字符串). 格式:lr_eval_string("{参数名}") ...
- 使用loadrunner进行压力测试之----post请求
1. 发送post请求时使用web_submit_data 如: web_submit_data("create",//事务名 "Action=http://bizhi. ...
- Loadrunner中参数和变量的使用
//字符串复制strcpy(str,"Hello ") ; //字符串连接strcat(str,"World !");lr_message("str: ...
- Loadrunner脚本编程(1)-大体思路
http://www.360doc.com/content/10/0806/13/1698198_44076570.shtml 就目前的了解.Loadrunner的脚本语言其实和C没什么区别.他内部的 ...
- Loadrunner C 编程_1
就目前的了解.Loadrunner的脚本语言其实和C没什么区别.他内部的好多机制都是C实现的. 不过是一种“类C” 所以我从几个方面分析 1:定义常量变量和C一样 2:在LR中,C的变量和LR的参数是 ...
- LR参数和变量
一.参数: 1. 在LR函数中可以直接使用参数.参数必须在双引号“”中才能应用.大部分情况下,可以直接用参数代替函数中双引号内的数据.如下使用方法: lr_save_string("http ...
随机推荐
- 使用python的subprocess模块调用linux系统命令
subprocess模块主要有call().check_call().check_output().Popen()函数,简要描述如下: Main API ======== call(...): Run ...
- 086、一张表搞定各种Docker监控方案(2019-05-08 周三)
参考https://www.cnblogs.com/CloudMan6/p/7736176.html 前面已经学习了 ps/top/stats.Sysdig.Weave Scope .cAdvi ...
- java静态代码块、静态方法、静态变量、构造代码块、普通代码块
一.静态代码块 1.在java类中(方法中不能存在静态代码块)使用static关键字和{}声明的代码块: public class CodeBlock{ static{ System.out.prin ...
- 1-Kubernetes基本概念
Kubernetes中的大部分概念如Node.Pod.Replication Controller.Service等都可以看作一种"资源对象",几乎所有的资源对象都可以通过Kube ...
- 机器学习python常用模块
.Pickle模块 打包,解压训练模型 .pysnooper 调试打印日志
- Codeforces Round #575 (Div. 3) B. Odd Sum Segments (构造,数学)
B. Odd Sum Segments time limit per test3 seconds memory limit per test256 megabytes inputstandard in ...
- Service_Worker XSS
0x00 简介 Service Worker 是 Chrome 团队提出和力推的一个 WEB API,用于给 web 应用提供高级的可持续的后台处理能力.该 WEB API 标准起草于 2013 年, ...
- php函数nl2br的反函数br2nl 将html中的br换行符转换为文本输入中的换行符
下面这几个方法将能够帮你解决这个问题. PHP版将html中的<br />换行符转换为文本框中的换行符: 代码如下: function br2nl($text){ return preg_ ...
- Kong组件构成及使用
Service: Service 顾名思义,就是我们自己定义的上游服务,通过Kong匹配到相应的请求要转发的地方 Service 可以与下面的Route进行关联,一个Service可以有很多Route ...
- OOP三大核心封装继承多态
OOP支柱 3 个核心:封装 继承 多态 封装就是将实现细节隐藏起来,也起到了数据保护的作用. 继承就是基于已有类来创建新类可以继承基类的核心功能. 在继承中 另外一种代码重用是:包含/委托,这种重用 ...