在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语言函数的更多相关文章

  1. LoadRunner中截取字符串

    LoadRunner中截取字符串 /*strchr和strrchr的区别*/ char *strTest1="citms citms"; char *strTest2,*strTe ...

  2. Python3中转换字符串编码

    在使用subprocess调用Windows命令时,遇到了字符串不显示中文的问题,源码如下:#-*-coding:utf-8-*-__author__ = '$USER' #-*-coding:utf ...

  3. JavaScript中有对字符串编码的三个函数:escape,encodeURI,encodeURIComponent

    JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...

  4. loadrunner中切割字符串

    下面函数的作用: http://blog.csdn.net/hgj125073/article/details/8447605 通过-与: 字符切割字符串,即-与:字符已经被\0 字符取代 char  ...

  5. js中对new Date() 中转换字符串方法toLocaleString的使用

    提供特定于区域设置的日期和时间格式. dateTimeFormatObj = new Intl.DateTimeFormat([locales][, options]) dateTimeFormatO ...

  6. Django学习路26_转换字符串大小写 upper,lower

    在 urls 中注册 url(r'getstr',views.getstr) 在 views.py 中添加函数 def getstr(request): string = 'abc' string_2 ...

  7. Loadrunner中与事务相关的概念及函数

    一.事务 事务是指用户在客户端做一种或多种业务所需要的操作集,通过事务函数可以标记完成该业务所需要的操作内容:另一方面可以用来统计用户操作的相应时间.事务响应时间是指通过记录用户请求的开始时间和服务器 ...

  8. [Swift]字符串大小写转换,同时实现本地化或设置语言环境

    在NSString中提供了3种字符串大小写转换方式:1. 转换字符串大小写2. 转换字符串大小写,并实现本地化3. 转换字符串大小写,并设置语言环境. 一. 转换字符串大小写如果只是想单纯的将字符串进 ...

  9. Swift3.0语言教程字符串大小写转化

    Swift3.0语言教程字符串大小写转化 Swift3.0语言教程字符串大小写转化,在字符串中,字符串的格式是很重要的,例如首字母大写,全部大写以及全部小写等.当字符串中字符很多时,通过人为一个一个的 ...

随机推荐

  1. noip模拟赛 大芳的逆行板载

    题目背景 大芳有一个不太好的习惯:在车里养青蛙.青蛙在一个n厘米(11n毫米s)的Van♂杆子上跳来跳去.她时常盯着青蛙看,以至于突然逆行不得不开始躲交叉弹.有一天他突发奇想,在杆子上每1厘米为一个单 ...

  2. 集成淘宝sdk

    204是安全图片的问题, 请先检测以下几点: .请检测百川控制台是否已经申请初级API. .请检测百川控制台“我的产品后台”是否开通电商SDK应用.(重点检测很多用户疏忽这一点) .debug版本的可 ...

  3. 【题解】我也不是B ifrog 1112 二分 倍增

    题目传送门:http://ifrog.cc/acm/problem/1112 神奇的倍增二分,长见识了,在此做个记录,分享给大家. 懒得写题解了,直接转YJQ的:http://ifrog.cc/acm ...

  4. Itext2.0.8 和freemarker导出pdf

    这个是跟上一篇写的freemarker导出word是一块的.但是关联性不是很大.由于本人技术有限本篇导出也是根据网上大家的做出的demo混合而成.有不足的地方请大家指出.好改正,使以后看到的freem ...

  5. 疯狂java学习笔记

    面向对象: 从现实世界中客观存在的事物(对象)出发构造软件系统,并在软件系统构造中运用人类的自然思维方式,强调直接以现实世界中的事物为中心来思考,认识问题,并根据这些事务的本质特点,将他们抽象为系统中 ...

  6. Kubernetes - Getting Started With Kubeadm

    In this scenario you'll learn how to bootstrap a Kubernetes cluster using Kubeadm. Kubeadm solves th ...

  7. [异常篇]001.MySQL数据库忘记root密码解决办法[转载]

    MySQL数据库忘记root密码解决办法 1.在运行输入services.msc打开服务窗体,找到MYSQL服务.右键停止将其关闭.如图: 2.在运行输入cmd打开终端. 3.找到MYSQL的安装目录 ...

  8. Java设计模式の单例模式

    -------------------------------------------------- 目录 1.定义 2.常见的集中单例实现 a.饿汉式,线程安全 但效率比较低 b.单例模式的实现:饱 ...

  9. UVA 10886 Standard Deviation

    https://vjudge.net/problem/UVA-10886 计算标准差 碰到这种题将式子展开 #include<cmath> #include<cstdio> / ...

  10. Proxmap Sort

    这个排序是桶排序和基数排序的改进,理解了前两者,这个排序很容易理解 先回忆下桶排序是怎么回事,它与桶的区别在于入桶规则,桶排序里是1入1号桶,2入2号桶 这个排序把数字分区了,然后给出一个所谓的键,例 ...