Friday, 17 June 2016

How to put strtok function in a vugen script


put the logic after the co-related string

strtok is used when you get a long value from load runner seperated by delimiters for example,( and you want to seperate each value from the delimiters

logic()
{

extern char *strtok(char * string,const char * delimiters); // explicit declaration

char seperators[]= "(,";

char *token;

char c[100];
char * a[100];
char * d[100];
int i=0;

strcpy(c,lr_eval_string("{c_ContentGUID}"));

token= (char *) strtok(c,seperators); //Get the first token

if(!token)
{

lr_output_message("No token found in the string");

return (-1);

}

for(i=0; token !=NULL;i++)
{
 a[i]=token;

lr_output_message("%s", a[i]);

token= (char *) strtok(c,seperators); // get the next token

}

lr_save_string( a[6],"c_ContentGUID");

lr_save_string( a[5],"c_fgfgh");

lr_save_string( a[2],"c_xyz");
lr_save_string( a[1],"c_sret");

lr_output_message("c_ContentGUID : %s", lr_eval_string("{c_ContentGUID}"));


return 0;

}


4 comments:

  1. I am learning Qtp training in Chennai and now I am in intern, so I have referred a lot of blogs to enhance my skill test to get a good job ion testing industry, Thanks for the informative article.

    ReplyDelete
  2. Thanks for this nice post about Software Testing; I hope you will post more regarding software testing, keep blogging...
    Regards,
    Software testing training|Software training|Software testing training in Chennai

    ReplyDelete
  3. I was curious if you ever considered changing the layout of your site? It’s very well written;
    fire and safety course in chennai

    ReplyDelete