在LoadRunner中转换字符串大小写的C语言函数
在LoadRunner中转换字符串大小写的C语言函数 .
loadrunner语言ccharacterstringaction
封装ConvertToXXX函数:
//ConvertToUpper function
int ConvertToUpper(char * sInput, char * sNew)
{
sInput = (char *)strupr(sInput);
lr_save_string(sInput,sNew);
}
//ConvertToLower function
int ConvertToLower(char * sInput, char * sNew)
{
sInput = (char *)strlwr(sInput);
lr_save_string(sInput,sNew);
}
//ConvertToTitle function
int ConvertToTitle(char * sInput, char * sNew)
{
int i = 0, s = 0, l = 0;
char buf1[50];
char buf2[2];
char n;
// Copy a single character into the address of [n]
strncpy(&n,sInput+i,1);
// Copy the single character into buf2
sprintf(buf2,"%c",n);
// Convert the contents of buf2 to uppercase
strupr(buf2);
// Overwrite the contents of buf1 with buf2
strcpy(buf1,buf2);
i++;
while(i < strlen(sInput))
{
// Overwrite buf2 with one character
strncpy(&n,sInput+i,1);
sprintf(buf2,"%c",n);
// If the previous character was a space then make the current character upper case
if(s == 1){
strupr(buf2);
strcat(buf1,buf2);
s = 0;
}
// Otherwise convert to lower case and concatenate the current character into the string buf1
else{
strlwr(buf2);
strcat(buf1,buf2);
}
// If the current character is a space set the value of [s] to [1] so that the next character gets capitalised
if(strcmp(" ",buf2)==0)
{
s = 1;
}
i++;
}
lr_save_string(buf1,sNew);
}
使用ConvertToXXX转换函数:
Action()
{
lr_save_string("testing is believing","str");
ConvertToUpper(lr_eval_string("{str}"),"UpperStr");
lr_output_message(lr_eval_string("{UpperStr}"));
ConvertToLower(lr_eval_string("{str}"),"LowerStr");
lr_output_message(lr_eval_string("{LowerStr}"));
ConvertToTitle(lr_eval_string("{str}"),"TitleStr");
lr_output_message(lr_eval_string("{TitleStr}"));
return 0;
}
输出:
Virtual User Script started at : 2010-01-30 17:53:13
Starting action vuser_init.
Web Turbo Replay of LoadRunner 9.50 SP1 for WINXP; WebReplay96 build 7045 (May 27 2009 14:28:58) [MsgId: MMSG-27143]
Run Mode: HTML [MsgId: MMSG-26000]
Run-Time Settings file: "D:/xlsoft/LR/MyTest/ConvertToXXXX//default.cfg" [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(63): TESTING IS BELIEVING
Action.c(66): testing is believing
Action.c(69): Testing Is Believing
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
在LoadRunner中转换字符串大小写的C语言函数的更多相关文章
- LoadRunner中截取字符串
LoadRunner中截取字符串 /*strchr和strrchr的区别*/ char *strTest1="citms citms"; char *strTest2,*strTe ...
- Python3中转换字符串编码
在使用subprocess调用Windows命令时,遇到了字符串不显示中文的问题,源码如下:#-*-coding:utf-8-*-__author__ = '$USER' #-*-coding:utf ...
- JavaScript中有对字符串编码的三个函数:escape,encodeURI,encodeURIComponent
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- loadrunner中切割字符串
下面函数的作用: http://blog.csdn.net/hgj125073/article/details/8447605 通过-与: 字符切割字符串,即-与:字符已经被\0 字符取代 char ...
- js中对new Date() 中转换字符串方法toLocaleString的使用
提供特定于区域设置的日期和时间格式. dateTimeFormatObj = new Intl.DateTimeFormat([locales][, options]) dateTimeFormatO ...
- Django学习路26_转换字符串大小写 upper,lower
在 urls 中注册 url(r'getstr',views.getstr) 在 views.py 中添加函数 def getstr(request): string = 'abc' string_2 ...
- Loadrunner中与事务相关的概念及函数
一.事务 事务是指用户在客户端做一种或多种业务所需要的操作集,通过事务函数可以标记完成该业务所需要的操作内容:另一方面可以用来统计用户操作的相应时间.事务响应时间是指通过记录用户请求的开始时间和服务器 ...
- [Swift]字符串大小写转换,同时实现本地化或设置语言环境
在NSString中提供了3种字符串大小写转换方式:1. 转换字符串大小写2. 转换字符串大小写,并实现本地化3. 转换字符串大小写,并设置语言环境. 一. 转换字符串大小写如果只是想单纯的将字符串进 ...
- Swift3.0语言教程字符串大小写转化
Swift3.0语言教程字符串大小写转化 Swift3.0语言教程字符串大小写转化,在字符串中,字符串的格式是很重要的,例如首字母大写,全部大写以及全部小写等.当字符串中字符很多时,通过人为一个一个的 ...
随机推荐
- Atlantis HDU - 1542 (线段树扫描线)
There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some ...
- 【转载】Innodb共享表空间VS独立表空间
http://www.mysqlsupport.cn/innodb%E5%85%B1%E4%BA%AB%E8%A1%A8%E7%A9%BA%E9%97%B4vs%E7%8B%AC%E7%AB%8B%E ...
- zoj 2369 Two Cylinders
zoj 2369 Two Cylinders 链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2369 题意:已知两个无 ...
- poj 3498 最大流
March of the Penguins Time Limit: 8000MS Memory Limit: 65536K Total Submissions: 4809 Accepted: ...
- Java中JAVA_HOME与CLASSPATH的解析(转)
很多人在初学Java的时候经常会被书中介绍的一堆环境变量的设置搞得头昏脑胀,很多书中都会在初装JDK的时候让他大家设置JAVA_HOME环境变量,在开发程序的时候设置CLASSPATH环境变量,而很多 ...
- 上下文路径request.getContextPath();与${pageContext.request.contextPath}
(1) request.getContextPath();与${pageContext.request.contextPath}都是获取上下文路径: 1. request.getContextPath ...
- CentOS6.8 安装rar解压缩
wget http://www.rarsoft.com/rar/rarlinux-x64-5.4.0.tar.gz tar -zxvf rarlinux-x64-5.4.0.tar.gz cd rar ...
- Apache 文件服务器
1.安装apache服务器yum install httpd 2.启动httpd服务service httpd start 3.查看httpd服务器的版本httpd -v 4.修改访问端口和文件路径, ...
- IntentServicce;Looper;long-running task
7. If you want to carry on a long-running task, what do you need to do? IntentService:Service Servic ...
- HDU 1069 Monkey and Banana (dp)
题目链接 Problem Description A group of researchers are designing an experiment to test the IQ of a monk ...