Microsoft KB Archive/33489

= QB 4.00b UPDATE.DOC: Adds SLEEP Statement to Suspend =

Article ID: 33489

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q33489



SUMMARY
The following information was taken from the QuickBasic Version 4.00b UPDATE.DOC file. It describes features that have been added since Microsoft QuickBasic Version 4.00 was released.

This information applies to Microsoft QuickBasic Versions 4.00b and 4.50 for MS-DOS, to Microsoft Basic Compiler Versions 6.00 6.00b, and to Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.



MORE INFORMATION
New Statement: SLEEP

Action: Suspends the execution of a Basic program

Syntax: SLEEP

Remarks:

In this syntax the optional parameter determines how many seconds to suspend the program. SLEEP suspends a QuickBasic program until one of the following three events occurs:

1. The time period specified in the SLEEP statement has elapsed.

2. A key is pressed.

3. An enabled QuickBasic event occurs.

A QuickBasic event is one that you can trap with an ON statement such as ON COM or ON KEY. Note that a QuickBasic event does not interrupt the suspension caused by SLEEP unless its trap is active when the event occurs. That is, the trap must have been set up with an ON statement, turned on with an ON statement, and not disabled with OFF or STOP. Note, too, that SLEEP responds only to actual keystrokes that occur after the SLEEP statement executes; SLEEP ignores characters that were stored in the keyboard buffer before the SLEEP statement executes.

If you execute SLEEP with a time period of 0 (zero), or without specifying any time period, the program is suspended for an indefinite period. In this case, only a keystroke or QuickBasic event can interrupt the suspension.

Example:

The following program suspends its execution for 20 seconds. Because the sample program has no ON EVENT statement, the only way to interrupt its suspension prior to the end of the 20-second delay is by pressing a key.

PRINT &quot;Taking a twenty-second timeout...&quot; SLEEP 20 PRINT &quot;Play ball!&quot;

Additional query words: QuickBas BasicCom

Keywords: KB33489

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.