惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
博客园 - 聂微东
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
腾讯CDC
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
博客园_首页
F
Fortinet All Blogs
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
博客园 - 【当耐特】
量子位
博客园 - 叶小钗
M
MIT News - Artificial intelligence
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
MyScale Blog
MyScale Blog
爱范儿
爱范儿
The Cloudflare Blog
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog

博客园 - pent

记一次有内存泄漏的性能测试 持续关注质量——产品属于每一个人 Bug bash、ZBB与软件质量 Jira升级小插曲 遭遇QTP描述性编程的对象识别错误 如何使用ping和tracert命令检测丢包 软件测试招聘之难【转】 何经华:我在职场30年 买房炒股是中国百姓最理性的选择 自动化测试十大要点[转] 质量名言 让你受益匪浅的IT培训语录 一千元的代价 如何使用Oracle sql loader批量导入数据 LoadRunner中多值关联的3种处理方式 【推荐】-Web下的整体测试 QTP User-Defined Function 学习经验汇总 LoadRunner Settings for Web Timeout Error 薪资留人还是情感留人?
LoadRunner字符串与参数的操作及转换技巧
pent · 2007-12-17 · via 博客园 - pent

刚开始学LR时,经常搞不清楚变量和参数的区别与用法,最近在一次脚本编写中,整理出来的一些小技巧,与大家一起分享。

//字符串复制
strcpy(str,"Hello ") ;

//字符串连接
strcat(str,"World !");
lr_message("str: %s",str);


//变量转为参数,将变量str的值存到参数Param中
lr_save_string(str,"Param");


//参数复制
lr_save_string(lr_eval_string("{Param}"),"Param_1");

//参数转为变量
strcpy(str1,lr_eval_string("{Param_1}"));
lr_message("str1: %s",str1);


//参数名称格式化输出到变量中
sprintf(str2,"{Param_%d}",1);
lr_message("str2: %s",lr_eval_string(str2));


运行结果:
str: Hello World !
vuser_init.c(14): Notify: Saving Parameter "Param = Hello World !"
vuser_init.c(19): Notify: Parameter Substitution: parameter "Param" =  "Hello World !"
vuser_init.c(19): Notify: Saving Parameter "Param_1 = Hello World !"
vuser_init.c(24): Notify: Parameter Substitution: parameter "Param_1" =  "Hello World !"
str1: Hello World !
vuser_init.c(30): Notify: Parameter Substitution: parameter "Param_1" =  "Hello World !"
str2: Hello World !