在LoadRunner中轉換字串大小寫的C語言函式
封裝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.
參考:
相關文章
- MySQL字串函式 字串大小寫轉換MySql字串函式
- C語言atoi()函式:將字串轉換成int(整數)C語言函式字串
- 字串-大小寫轉換字串
- C語言---整型字串轉換C語言字串
- string大小寫轉換函式函式
- (C++字串大小寫轉換)相似的句子C++字串
- JavaScript字串大小寫轉換JavaScript字串
- c語言字串,數字轉換C語言字串
- Python中怎麼轉換字串大小寫Python字串
- 字串大小寫轉換和字串的比較字串
- c語言字串處理函式大全C語言字串函式
- javascript字串大小寫轉換效果JavaScript字串
- 大小寫轉換函式(財務應用)函式
- c語言函式庫(轉)C語言函式
- C語言相關的基礎字串函式C語言字串函式
- C語言“字串-數字”之間的轉換C語言字串
- 字串中大小寫轉換輸出字串
- C語言函式手冊:c語言庫函式大全|C語言標準函式庫|c語言常用函式查詢C語言函式
- C語言-字串函式的實現(一)之strlenC語言字串函式
- C語言-字串函式的實現(五)之strstrC語言字串函式
- 在LoadRunner中查詢和替換字串字串
- C語言的隱式型別轉換C語言型別
- 在 Linux 命令列中轉換大小寫Linux命令列
- 【C語言】常用的字串函式及相關函式的自我實現C語言字串函式
- 【C語言】編寫一個函式reverse_string(char * string) 實現:將引數字串中的字元反向排列。要求:不能使用C函式庫中的字串操作函式。C語言函式字串字元
- python 中字串大小寫轉換薦Python字串
- C 語言整數與字串的相互轉換介紹字串
- C語言常用字串操作函式總結C語言字串函式
- 【C語言】字串複製。(不能使用strcpy函式)C語言字串函式
- 【C語言】編寫一個函式,將一個數字字串轉換成該字串對應的數字(包括正整數、負整數)。C語言函式字串
- 類似於C語言的printf函式 (轉)C語言函式
- c語言字串與整形,浮點數...相互轉換C語言字串
- 大小寫互換-"數字字串"轉換成數字字串
- C語言實現字串拷貝函式的幾種方法C語言字串函式
- C語言 execve()函式C語言函式
- C語言常用函式C語言函式
- 1138:將字串中的小寫字母轉換成大寫字母(C C++)字串C++
- C語言putc()函式:寫檔案函式(將一指定字元寫入檔案中)C語言函式字元