Example: lr_get_attrib_double / lr.get_attrib_double

lr_get_attrib_double

In the following example, lr_get_attrib_double retrieves the value of the time parameter from the mdrv command line string that was used to run the script.

D:\LoadRunner78\bin\mdrv.exe
     -usr D:\LR_Tests\C\get_attribute\get_attribute.usr
     -out D:\LR_Tests\C\get_attribute\out 
    -time 1.5 
    -secondsInYear 30758400 
    -MrsCollins Charlotte

lr_get_attrib_double assigns the value to a variable, wait_time. This variable is incorporated into the script and sets how long to wait between loops.

Action() {
	double wait_time;
	long secInYear;
	char *mrsCollins;
	long t;
	int i, loops = 3;   
	wait_time=lr_get_attrib_double("time");
	secInYear = lr_get_attrib_long ("secondsInYear");
	mrsCollins =lr_get_attrib_string ("MrsCollins");
	if ( wait_time <= 0 ){
	    lr_message("Illegal time value = %f \n", wait_time);
	    return;
	} else
	{
	    lr_message("Wait time value = %f", wait_time);
	    lr_message("The number of seconds in a year is %ld", secInYear);
	    lr_message("Mr. Collins' wife is named %s Lucas", mrsCollins);
	}
	 for (i=0; i < loops; ++i) {
	    time(&t);
	    lr_message("Time and date: %s", ctime(&t));
	    lr_think_time(wait_time);
	    }
	 time(&t);
	 lr_message("time and date: %s", ctime(&t));}
	return 0;
}

 

Example: Output:
            
Starting action Action.     [MsgId: MMSG-15919]
Wait time value = 1.500000     [MsgId: MMSG-17999]
The number of seconds in a year is 30758400  [MsgId: MMSG-17999]
Mr. Collins' wife is named Charlotte Lucas   [MsgId: MMSG-17999]
Time and date: Wed Jan 07 16:12:09 2004 [MsgId: MMSG-17999]
Action.c(29): lr_think_time: 1.50 seconds.   [MsgId: MMSG-15948]
Time and date: Wed Jan 07 16:12:10 2004 [MsgId: MMSG-17999]
Action.c(29): lr_think_time: 1.50 seconds.   [MsgId: MMSG-15948]
Time and date: Wed Jan 07 16:12:12 2004    [MsgId: MMSG-17999]
Action.c(29): lr_think_time: 1.50 seconds.   [MsgId: MMSG-15948]
time and date: Wed Jan 07 16:12:13 2004     [MsgId: MMSG-17999]
Ending action Action.     [MsgId: MMSG-15918]