Example: lr_get_attrib_string

In the following example, lr_get_attrib_string retrieves the name of the host string value from the mdrv command line string that was used to run the script.

D:\LoadRunner\bin\mdrv.exe 
    -usr D:\LR_Tests\C\get_attribute\get_attribute.usr 
    -out D:\LR_Tests\C\get_attribute\out 
    -host sun2   -loop 4   -time 1.5

where host, loop and time are mdrv command line parameters to be used in get_attribute.usr. lr_get_attrib_string assigns the value of parameter "host" to the variable "server".

vuser_init() {
/* LPCSTR is a char * .  */
     LPCSTR server;
     LPCSTR user = "tomh";
     LPCSTR password = "pwd";
     LPCSTR connect[10];
     server=lr_get_attrib_string("host");
     if (server==NULL){
          lr_error_message("Failed to login. Unknown host.\n");
          return(0);
     }
     
/*Prepare a string with login information */
     sprintf(connect,"%s%s%s", user, password, server);
     lr_message("%s", connect);
     return 0;