SLEEP: Suspending Execution for a Given Number of Seconds

How to:

Available Languages: reporting, Maintain

The SLEEP function suspends execution for the number of seconds you specify as its input argument.

This function is most useful in Dialogue Manager when you need to wait to start a specific procedure. For example, you can start a FOCUS Database Server and wait until the server is started before initiating a client application.

Syntax: How to Suspend Execution for a Specified Number of Seconds

SLEEP(delay, output);

where:

delay

Numeric

Is the number of seconds to delay execution. The number can be specified down to the millisecond.

output

Numeric

Is the name of a field or a format enclosed in single quotation marks. The value returned is the same value you specify for delay.

Example: Suspending Execution for Four Seconds

The following example computes the current date and time, suspends execution for 4 seconds, and computes the current date and time after the delay:

TABLE  FILE VIDEOTRK                       
PRINT TRANSDATE NOPRINT                    
COMPUTE                                    
START_TIME/HYYMDSa = HGETC(8, START_TIME); 
DELAY/I2 = SLEEP(4.0, 'I2');               
END_TIME/HYYMDSa = HGETC(8, END_TIME);     
IF RECORDLIMIT EQ 1                        
END                                        

The output is:

START_TIME             DELAY  END_TIME             
----------             -----  --------             
2007/10/26  5:04:36pm      4  2007/10/26  5:04:40pm