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

推荐订阅源

M
MIT News - Artificial intelligence
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
J
Java Code Geeks
G
Google Developers Blog
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
月光博客
月光博客
B
Blog
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
博客园_首页
人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
Jina AI
Jina AI
S
SegmentFault 最新的问题
H
Help Net Security
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
Google DeepMind News
Google DeepMind News

博客园 - 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 !