'===========================================================================
' Subject: Pause Function                     Date: 03-15-02 (  :  )       
'  Author: Joe B.                             Code: IB                     
'  Origin: TronDoc@mail.wowmail.com         Packet: IBASIC.ABC
'===========================================================================
'TronDoc PAUSE(seconds) UserDefinedFunction 
' ©2002 by: the elecTRONics DOCtor - TronDoc@USA.com 
' Name: PAUSE() 
' Type: UDF {user defined function} 
' Date: 2002.03.12.0233 Version: 0.1 
' Language: IBASIC 
' O.S.: winDoze 
' Mode: winDozeWin/winDozeCons 
' Externals Required: winAPI 
' Purpose: can be used for a delay or time-out timer 
' Description: called with a number of seconds that you 
' wish the timer to run before it expires... 
' Distribution License: 
' PublicDomain: free for any purpose 
' Other Credits: Pyxia/IBASIC  

DECLARE "kernel32",GetTickCount(),int 
DECLARE PAUSE(TimeToWait:INT) 

DEF KEYPRESS$:STRING 
DEF StartTime,TimeToWait,CountNow:INT
 
' TimeToWait argument is in seconds 

TimeToWait=3  

OPENCONSOLE 
' Pause for 3 seconds 
PAUSE(TimeToWait) 
'PRINT "DONE waiting!" 
IF KEYPRESS$="" 
	PRINT "YOU WERE TOO SLOW -- NO KEYPRESS RECORDED!" 
ELSE 
	PRINT "SPEEDY GONZALES! YOU PRESSED: ",KEYPRESS$ 
ENDIF 
DO
UNTIL INKEY$<>"" 
CLOSECONSOLE 
END  
SUB PAUSE(TimeToWait) 
' convert TimeToWait into milliseconds 
TimeToWait=TimeToWait*1000 
' get the time the routine starts 
StartTime = GetTickCount() 
' calculate the time the routine should end 
TimeToWait = StartTime + TimeToWait 
' loop and do stuff while keeping 
' an eye on the timer 
WHILE CountNow < TimeToWait 
	CountNow = GetTickCount() 
' Here you can do things like check 
' for a keypress until the timer expires.. 
	PRINT "waiting...",CountNow,TimeToWait 
	KEYPRESS$=INKEY$ 
	IF KEYPRESS$<>"" THEN CountNow=TimeToWait 
ENDWHILE 
RETURN 
' Windoze98 32Mb p150 NO directX NO IE 
' the elecTRONics DOCtor	
