在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. UVA:11183:Teen Girl Squad (有向图的最小生成树)

    Teen Girl Squad Description: You are part of a group of n teenage girls armed with cellphones. You h ...

  2. DEBUG宏

    4.8.6.运算中的临时匿名变量4.8.6.1.C语言和汇编的区别(汇编完全对应机器操作,C对应逻辑操作)(1)C语言叫高级语言,汇编语言叫低级语言.(2)低级语言的意思是汇编语言和机器操作相对应,汇 ...

  3. RabbitMQ基础概念(消息、队列、交换机)

    1.消息的确认 RabbitMQ需要对每一条发送的消息进行确认.消费者必须通过AMQP的basic.ack命令显式地向RabbitMQ发送一个确认,或者在订阅到队列的时候就将auto_ack参数设置为 ...

  4. [Leetcode] LRU 算法实现

    Design and implement a data structure for Least Recently Used (LRU) cache. It should support the fol ...

  5. 【Foreign】Uria [欧拉函数]

    Uria Time Limit: 20 Sec  Memory Limit: 512 MB Description 从前有个正整数 n. 对于一个正整数对 (a,b),如果满足 a + b ≤ n 且 ...

  6. 【BZOJ2850】巧克力王国 [KD-tree]

    巧克力王国 Time Limit: 60 Sec  Memory Limit: 512 MB[Submit][Status][Discuss] Description 巧克力王国里的巧克力都是由牛奶和 ...

  7. 【BZOJ】3790 神奇项链

    [算法](manacher+贪心)||(manacher+DP+树状数组/线段树) [题解] manacher求回文串,后得到线段,做一点计算映射回原串线段. 然后问题转化为可重叠区间线段覆盖问题,可 ...

  8. Windows Phone 8.1基础教程(1) 页面导航、弹出框

    1. 跳转到其他页面 Frame.Navigate(typeof(页面),参数); 2. 后退回历史页面 Frame.GoBack(); 3. 回跳时判断 if(e.NavigationMode == ...

  9. 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 H. Skiing (拓扑排序+假dp)

    题目链接:https://nanti.jisuanke.com/t/16957 题目: In this winter holiday, Bob has a plan for skiing at the ...

  10. httpd -v command not found

    使用 find / -name "apachectl"查找文件目录下执行 ./apachectl -v