[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
##############################################################################
###+---------+################################################################
#+-| DELAY() |-----------------------------------------------------+##########
#| +---------+ Delays number_seconds while waiting for a keystroke |##########
#+-----------------------------------------------------------------+##########
##############################################################################
##############################################################################
#+--| Summary |------------+##################################################
#| #INCLUDE io.hdr |##################################################
#+-------------------------+##################################################
##############################################################################
##############################################################################
#+--| Syntax |-----------------------------------+############################
#| FUNCTION UINT delay PROTOTYPE |############################
#| PARAMETERS VALUE UINT number_seconds |############################
#+-----------------------------------------------+############################
##############################################################################
##############################################################################
#######+---| Description |---------------------------------------------+######
#######| The delay() function delays number_seconds while waiting for |######
#######| a keystroke. If no key is pressed within number_seconds, |######
#######| then delay() returns 0 else delay() returns the key. The key |######
#######| is removed from the keyboard buffer. |######
#######| ------------------------------------------------------------- |######
#######| The header file keys.hdr contains defines for the keyboard |######
#######| characters. |######
#######+---------------------------------------------------------------+######
##############################################################################
##############################################################################
#########+--| Example 1 |-------------------------------------------+#########
#########| * Wait 5 minutes for a keystroke before |#########
#########| * aborting a process. |#########
#########| |#########
#########| ? "Press any key to continue..." |#########
#########| k = delay( 60*5 ) |#########
#########| IF k = 0 |#########
#########| DO abort_program |#########
#########| ENDIF |#########
#########| {...} |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 2 |-------------------------------------------+#########
#########| * file: \force\sample\noburn.prg |#########
#########| * (** source code included with compiler **) |#########
#########| * This function clears the screen and then |#########
#########| * prints a "moving" message while waiting for |#########
#########| * a key. This prevents "screen burn". |#########
#########| |#########
#########| FUNCTION INT no_burn_key |#########
#########| PARAMETERS CONST CHAR the_message |#########
#########| VARDEF |#########
#########| INT current_screen, r, c, k |#########
#########| ENDDEF |#########
#########| |#########
#########| *--- if there is a key in buffer...just return |#########
#########| * without saving screen, etc.. |#########
#########| |#########
#########| IF is_key() <> 0 |#########
#########| RETURN get_key() |#########
#########| ENDIF |#########
#########| |#########
#########| *--- save the screen and initialize our screen |#########
#########| * coordinates to 0 |#########
#########| |#########
#########| current_screen = savescrn( 0,0,24,79 ) |#########
#########| STORE 0 TO r, c |#########
#########| |#########
#########| *--- move our message around while waiting for a key |#########
#########| |#########
#########| REPEAT |#########
#########| @ r,c ?? the_message |#########
#########| k = delay( 1 ) && delay a second |#########
#########| @ r,c ?? space( len( the_message ) ) |#########
#########| |#########
#########| *--- increment our row/column positions |#########
#########| |#########
#########| r = r + 1 |#########
#########| IF r > 24 |#########
#########| r = 0 |#########
#########| ENDIF |#########
#########| IF c + len( the_message ) > 79 |#########
#########| c = 0 |#########
#########| ENDIF |#########
#########| UNTIL k <> 0 |#########
#########| restorescrn( current_screen ) |#########
#########| RETURN k |#########
#########| ENDPRO |#########
#########+----------------------------------------------------------+#########
##############################################################################
See Also:
get_key()
inkey()
is_key()
lastkey()
no_burn_key()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson