LoadRunner???????????????????
???????????? ???????[ 2016/7/28 11:42:56 ] ????????LoadRunner ??????????
??????Щ???????????????????????0???????????????????
??????LoadRunner?п????????????????????????????
/*
Function to pad a string to x characters adding the required character at the start of the string
(Note string length limited by length of the array)
Author: Steven Woodcock?? Sopra Group
Inputs:
strCharToPad - The String that requires to be padded out i.e. "123456"
cParamName - The name of the parameter you want the end value to be saved to
iValLength - The length you want the string to be padded out to i.e. 9
cValueToAdd - The character you want to pad the string out with?? must be a single character i.e. "0"
Outputs:
Creates a LoadRunner parameter of a name specified in the input 'cParamName'
*/
int lr_padstr(char* cCharToPad?? char* cParamName?? int iValLength?? char* cValueToAdd){
char cTemp[1024] = "";
int iLoop = 0;
int iMainLoop = 0;
int iSubLoop = 0;
for(iMainLoop = 0; iMainLoop < iValLength; iMainLoop++){
if (iMainLoop == strlen(cCharToPad)) {
iLoop = iValLength - iMainLoop;
for (iSubLoop = 0; iSubLoop < iLoop; iSubLoop++) {
strcat(cTemp?? cValueToAdd);
}
}
}
strcat(cTemp?? cCharToPad);
lr_save_string(cTemp?? cParamName);
}
????lr_padstr?????????????????????????????????????????????????????LoadRunner?????С????????????lr_padstr.h?????У???LoadRunner??????????
#include "lr_padstr.h"
Action()
{
// For the lr_padstr function
char * cShortValue = "123";
// For the sprintf function
char cPaddedValue[8] ="";
int iShortValue = 123;
int i;
// The lr_padstr function?? written by Steven Woodcock can be used to pad with zeroes
lr_padstr(cShortValue??"pPaddedParameter"??8??"0");
lr_output_message("Padded value is %s"?? lr_eval_string("{pPaddedParameter}"));
// The PadToX function can also be used to pad with other characters (e.g. x)
lr_padstr(cShortValue??"pPaddedParameter"??8??"x");
lr_output_message("Padded value is %s"?? lr_eval_string("{pPaddedParameter}"));
return 0;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11