lr_get_attrib_double

Returns a double type value of an argument passed to the script run.

double lr_get_attrib_double( char *argument_name );
Alphabetical Listing - C Language Utility Functions

Arguments

NameComments
argument_nameThe name of an argument that can be interpreted as a double value.

The lr_get_attrib_double function returns the value of an argument of type double precision floating point that was passed to the run of the script.

To view the arguments passed to a script run, see mdrv_cmd.txt in the script folder.

Return Values

If this function succeeds, it returns the value of the argument. If the parameter does not exist or if its value is not consistent with the type (for example a flag parameter), the function returns -1.

Parameterization

You cannot use standard parameterization for any arguments in this function.

Example

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:\<product>\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]