在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. 查看Django版本

    python -m django --version dd

  2. [LeetCode] 数组的最长连续数, O(n)解法

    Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...

  3. maven工程pom.xml报Missing artifact net.sf.jasperreports:jasperreports:jar:6.2.0

    有时maven工程的pom.xml报以下类型错误: Description Resource Path Location TypeMissing artifact net.sf.jasperrepor ...

  4. 省队集训 Day3 陈姚班

    [题目大意] 给一张网格图,上往下有流量限制,下往上没有,左往右有流量限制. $n * m \leq 2.5 * 10^6$ [题解] 考场直接上最大流,50分.竟然傻逼没看出狼抓兔子. 平面图转对偶 ...

  5. 【BZOJ】1699 [Usaco2007 Jan]Balanced Lineup排队

    [算法]线段树 #include<cstdio> #include<cctype> #include<algorithm> using namespace std; ...

  6. Spring 框架的设计理念与设计模式分析(山东数漫江湖)

    Spring 的骨骼架构 Spring 总共有十几个组件,但是真正核心的组件只有几个,下面是 Spring 框架的总体架构图: 图 1 .Spring 框架的总体架构图 从上图中可以看出 Spring ...

  7. 暑假集训——cf热身赛部分题有感加其题解

    刚刚开始集训,集训队队长暂时还没有拉专题,而是拉了部分codeforces上过题人数在2000左右的题组成了一场热身赛(其实就是一场练习),花了一天时间终于把它刷完了,其中很多题让我学到了很多骚操作, ...

  8. Angular2.0 基础: 环境搭建

    最近在学习Angular2的使用,其实看过Angular2 文档的都知道,相比于之前的Angular1,Angular2 的改动还是挺大的. 而对于‘angular2 的本地开发环境的搭建的中,我们首 ...

  9. Eureka Server的高可用

    Eureka Server进行互相注册的方式来实现高可用的部署,所以我们只需要将Eureke Server配置其他可用的serviceUrl就能实现高可用部署 创建application-peer1. ...

  10. 使用Sysmon分析宏病毒(Macros Downloader)

    样本为一个Word文件,Virustotal地址: https://www.virustotal.com/#/file/f8aede78ad92bd28f5f699b677d7d5fd362c8be8 ...