Action()
{
char a,b,c;
char *value="040;350;07/05/2012";
char *temp;
lr_save_string(value,"TokenValue_1");
temp=(char *)strtok(lr_eval_string("{TokenValue_1}"),";");
lr_save_string(temp,"TokenValue1");
a=lr_output_message("%s",lr_eval_string("{TokenValue1}"));
lr_output_message("the string a = %s",lr_eval_string("{TokenValue1}"));
temp=(char *) strtok(NULL,";");
lr_save_string(temp,"TokenValue2");
b=lr_output_message("%s",lr_eval_string("{TokenValue2}"));
lr_output_message("the string b = %s",lr_eval_string("{TokenValue2}"));
temp=(char *) strtok(NULL,";");
lr_save_string(temp,"TokenValue3");
c=lr_output_message("%s",lr_eval_string("{TokenValue3}"));
lr_output_message("the string c = %s",lr_eval_string("{TokenValue3}"));
return 0;
} Action()
{
char a,b,c;
char *value="040;350;07/05/2012";
char *temp;
lr_save_string(value,"TokenValue_1");
temp=(char *)strtok(lr_eval_string("{TokenValue_1}"),";");
lr_save_string(temp,"TokenValue1");
a=lr_output_message("%s",lr_eval_string("{TokenValue1}"));
lr_output_message("the string a = %s",lr_eval_string("{TokenValue1}"));
temp=(char *) strtok(NULL,";");
lr_save_string(temp,"TokenValue2");
b=lr_output_message("%s",lr_eval_string("{TokenValue2}"));
lr_output_message("the string b = %s",lr_eval_string("{TokenValue2}"));
temp=(char *) strtok(NULL,";");
lr_save_string(temp,"TokenValue3");
c=lr_output_message("%s",lr_eval_string("{TokenValue3}"));
lr_output_message("the string c = %s",lr_eval_string("{TokenValue3}"));
return 0;
}
==================================
Action()
{
int i;
char value [100];
web_reg_save_param("Table", "LB=",RB=","Ord=ALL",LAST);
LB should be a href and RB be >
web_url("MERCURY", "URL=http://www.mercury.com", LAST );
for (i=1; i<= atoi(lr_eval_string("{Table_count}")); i++){
sprintf(value,"{Table_%d}",i);
lr_output_message("Value %d = %s ",i,lr_eval_string(value));
}
return 0;
- See more at: http://www.techsquids.com/pt/strtok-loadrunner/#sthash.QgUWWKck.dpuf
{
char a,b,c;
char *value="040;350;07/05/2012";
char *temp;
lr_save_string(value,"TokenValue_1");
temp=(char *)strtok(lr_eval_string("{TokenValue_1}"),";");
lr_save_string(temp,"TokenValue1");
a=lr_output_message("%s",lr_eval_string("{TokenValue1}"));
lr_output_message("the string a = %s",lr_eval_string("{TokenValue1}"));
temp=(char *) strtok(NULL,";");
lr_save_string(temp,"TokenValue2");
b=lr_output_message("%s",lr_eval_string("{TokenValue2}"));
lr_output_message("the string b = %s",lr_eval_string("{TokenValue2}"));
temp=(char *) strtok(NULL,";");
lr_save_string(temp,"TokenValue3");
c=lr_output_message("%s",lr_eval_string("{TokenValue3}"));
lr_output_message("the string c = %s",lr_eval_string("{TokenValue3}"));
return 0;
} Action()
{
char a,b,c;
char *value="040;350;07/05/2012";
char *temp;
lr_save_string(value,"TokenValue_1");
temp=(char *)strtok(lr_eval_string("{TokenValue_1}"),";");
lr_save_string(temp,"TokenValue1");
a=lr_output_message("%s",lr_eval_string("{TokenValue1}"));
lr_output_message("the string a = %s",lr_eval_string("{TokenValue1}"));
temp=(char *) strtok(NULL,";");
lr_save_string(temp,"TokenValue2");
b=lr_output_message("%s",lr_eval_string("{TokenValue2}"));
lr_output_message("the string b = %s",lr_eval_string("{TokenValue2}"));
temp=(char *) strtok(NULL,";");
lr_save_string(temp,"TokenValue3");
c=lr_output_message("%s",lr_eval_string("{TokenValue3}"));
lr_output_message("the string c = %s",lr_eval_string("{TokenValue3}"));
return 0;
}
==================================
Action()
{
int i;
char value [100];
web_reg_save_param("Table", "LB=",RB=","Ord=ALL",LAST);
LB should be a href and RB be >
web_url("MERCURY", "URL=http://www.mercury.com", LAST );
for (i=1; i<= atoi(lr_eval_string("{Table_count}")); i++){
sprintf(value,"{Table_%d}",i);
lr_output_message("Value %d = %s ",i,lr_eval_string(value));
}
return 0;
- }
????????????????///////////////////////???????????????????
Example 2:
xtern char * strtok(char * string, const char * delimiters ); // Explicit declaration
char String_org[] = “http://localhost/app/myapp:8080”; // original string
char delimiter[] = “/:”;
char * token;
token = (char *)strtok(String_org, delimiter); // capture 1st sub string based on defined delimiter
if (!token) {
lr_output_message (“No tokens found in string!”);
return( -1 );
}
while (token != NULL ) { // While valid tokens are returned
lr_output_message (“%s”, token );
token = (char *)strtok(NULL, delimiter); // Get the next token
}
No comments:
Post a Comment