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 ...
随机推荐
- 说说 MicroPython 的项目整体架构
今天来说说 MicroPython 的架构情况,如果有必要我会做一些源码分析的文章供大家参考. 先来认识一下 MicroPython 整体情况,可以从软件的角度上去看待,首先我们拿到 MicroPyt ...
- 使用油猴子 greasemonkey xx 百度 ...
百度首页在登录以后很恶心 没事弹出点垃圾新闻来污染眼球 搜索结果右下角的今日排行榜也是没事就出现垃圾的东西 所以让我们也xx一下百度.. // ==UserScript== // @name 清理百度 ...
- static静态和非静态详解
static 作为Java中的一个关键字,用于修饰方法.成员变量(Field),统称为成员. 有static修饰的成员 属于类 1.方法称为静态方法(类方法),Field称为类的属性. 2.静态成 ...
- php判断变量是否为数字is_numeric()
is_numeric — 检测变量是否为数字或数字字符 <?php $tests = array( "31", 1380, "1e4", "no ...
- windows2008r2防火墙设置一例
有台dell R420服务器,系统windows2008r2 扫描出安全漏洞,按照默认开启防火墙,结果远程桌面上不去了,远程桌面端口号是10086,需要在 控制面板\所有控制面板项\Windows 防 ...
- QT中获取选中的radioButton的两种方法
QT中要获取radioButton组中被选中的那个按钮,可以采用两种如下两种办法进行: 方法一:采用对象名称进行获取 代码: 1 QRadioButton* pbtn = qobject_cast&l ...
- python之同步IO和异步IO
linux操作系统基础知识 用户空间和内核空间 操作系统的核心是内核,独立于普通的应用程序,可以访问受保护的内存空间,也有访问底层硬件设备的所有权限.为了保证用户进程不能直接操作内核保证内核的安全,操 ...
- ZROI 19.08.01 树上数据结构
1.总览 LCT 链分治(树剖) 点/边分治 2.点分治 一棵树,点有\(0/1\),多次修改,询问最远的两个\(1\)距离. 建出点分树,每个子树用堆维护:①最远的\(1\)距离:②它的每个儿子的① ...
- CSS-overflow-scroll 滑动粘手
长列表的滑动,CSS属性给了 overflow: auto:在IOS上可能会出现“粘手”效果,即滑动很慢.卡顿.粘手 解决: 启动硬件加速渲染: -webkit-overflow-scrolling: ...
- 任意修改网页内容JS代码
浏览器输入框执行,chrome需要粘贴后,需要在前面手打javascript: 因为粘贴的会自动过滤 javascript:document.body.contentEditable='true'; ...