一、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的使用的更多相关文章

  1. 转:lr_eval_string,lr_save_string 和 sprintf 的使用

    lr_eval_string,lr_save_string和 sprintf 函数使用介绍 一.lr_eval_string 使用介绍1.函数的主要作用:返回脚本中的一个参数当前的值,返回值类型:ch ...

  2. lr_save_string 和 sprintf 的使用

    lr_save_string 和 sprintf 的使用 一.lr_save_string 使用介绍1.该函数主要是将程序中的常量或变量保存为lr中的参数.格式: //将常量保存为参数 lr_save ...

  3. LoadRunner lr_eval_string() 函数使用及LR中变量、参数的简单使用

    lr_eval_string() 函数的主要作用:返回脚本中的一个参数当前的值, 返回值类型:char 一般多用在调试脚本时输出参数的值.具体用法如下:lr_output_message(" ...

  4. lr函数之lr_eval_string()函数的使用学习

    lr_eval_string() 函数的主要作用:返回脚本中的一个参数当前的值(从参数中取得对应的值,并且转换为一个字符串). 格式:lr_eval_string("{参数名}") ...

  5. 使用loadrunner进行压力测试之----post请求

    1. 发送post请求时使用web_submit_data 如: web_submit_data("create",//事务名 "Action=http://bizhi. ...

  6. Loadrunner中参数和变量的使用

    //字符串复制strcpy(str,"Hello ") ; //字符串连接strcat(str,"World !");lr_message("str: ...

  7. Loadrunner脚本编程(1)-大体思路

    http://www.360doc.com/content/10/0806/13/1698198_44076570.shtml 就目前的了解.Loadrunner的脚本语言其实和C没什么区别.他内部的 ...

  8. Loadrunner C 编程_1

    就目前的了解.Loadrunner的脚本语言其实和C没什么区别.他内部的好多机制都是C实现的. 不过是一种“类C” 所以我从几个方面分析 1:定义常量变量和C一样 2:在LR中,C的变量和LR的参数是 ...

  9. LR参数和变量

    一.参数: 1. 在LR函数中可以直接使用参数.参数必须在双引号“”中才能应用.大部分情况下,可以直接用参数代替函数中双引号内的数据.如下使用方法: lr_save_string("http ...

随机推荐

  1. Codeforces 1215C. Swap Letters

    传送门 好像是个挺显然的贪心 首先每次交换当然要尽量一次交换就多两个相同的位置 即 优先把 $\begin{bmatrix}a\\ b\end{bmatrix}$ 和 $\begin{bmatrix} ...

  2. python:count 函数

    API 一.string 中 某字符 的次数 str.count(sub, start= 0,end=len(string)) Args Annotations sub 搜索的子字符串 start 字 ...

  3. Vue.js实现分页

    效果图 代码 <!DOCTYPE html> <html lang="en" xmlns:v-bind="http://www.w3.org/1999/ ...

  4. mybatis中的动态代理应用(mapper对象)

    -----------------UserMapper的配置信息--------------------- <?xml version="1.0" encoding=&quo ...

  5. KVM虚拟化简介及安装

    kvm是基于图形化的linux操作的 安装图形化界面的知识点: 磁盘空间有两个词: 精简置备:我先在我系统里面去声明我要一个50G的空间,但是呢,我不会把50G都分给你,你用多少,我分给你多少,但是做 ...

  6. jenkins项目名称改后,同步nginx配置

    jenkins项目名称修改后,workspace的名称会同步更改,构建完了和原来的不是一个路径,如果每个前端项目一个单独的tomcat的话,需要更改nginx配置 /etc/nginx/conf.d

  7. Wannafly挑战赛22 C 多项式(大数,多项式极限)

    链接:https://ac.nowcoder.com/acm/contest/160/C 来源:牛客网 多项式 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言 ...

  8. htmlunit与Jsoup

    //这个函数的目的是在获取页面的同时,也获取链接对应的cookiepublic static HtmlPage getCookieAndHtml(String url)throws IOExcepti ...

  9. 【POJ3162】Walking Race 树形dp+单调队列+双指针

    题目大意:给定一棵 N 个节点的无根树,边有边权,现生成一个序列 d,d[i] 表示 i 号节点到树上其他节点距离的最大值.给定一个 m,求 d 序列中最大值和最小值之差不超过 m 的最长连续段的长度 ...

  10. python基础31[python IDE之Eclipse+PyDev]

    一 入门IDE作为python的初学者,在语法和类库学习阶段,我们可以使用以下简单使用的IDE:1) Python SDK 自带的IDEL(Python GUI)2) Komodo-Edit3) No ...