[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
##############################################################################
###+---------------+##########################################################
#+-| TIMER_ENTRY() |-------------------------------+##########################
#| +---------------+ Establishes a procedure to be |##########################
#| called in a periodic manner |##########################
#+-------------------------------------------------+##########################
##############################################################################
##############################################################################
#+--| Summary |-------------+#################################################
#| #INCLUDE tsr.hdr |#################################################
#+--------------------------+#################################################
##############################################################################
##############################################################################
#+--| Syntax |------------------------------------------------+###############
#| FUNCTION LOGICAL timer_entry PROTOTYPE |###############
#| PARAMETERS UNTYPED proc, VALUE LONG time_value, ; |###############
#| VALUE INT time_type, VALUE INT call_type |###############
#+------------------------------------------------------------+###############
##############################################################################
##############################################################################
#########+---| Description |----------------------------------------+#########
#########| The timer_entry() function establishes a procedure to be |#########
#########| called in a periodic manner. The parameter time_value |#########
#########| establishes the period of time while time_type |#########
#########| specifies HOW time_value is to be interpreted. Refer to |#########
#########| TIME TYPE TABLE for the proper value of time_type. |#########
#########| -------------------------------------------------------- |#########
#########| The timer_entry() function is helpful in programming |#########
#########| tasks that are typically accomplished in a "wait for a |#########
#########| key" procedure, such as printing the current time in the |#########
#########| upper right hand corner of the screen. |#########
#########| -------------------------------------------------------- |#########
#########| When time_value goes to zero then the procedure proc is |#########
#########| invoked only if the DOS environment defined by call_type |#########
#########| is TRUE. |#########
#########| -------------------------------------------------------- |#########
#########| call_type specifies when it is safe for proc to be |#########
#########| invoked. This is necessary to define because DOS could |#########
#########| be in the middle of a disk operation when proc is |#########
#########| called. If proc also performs disk I/O, then DOS will |#########
#########| be left in an unstable state. Refer to DOS CALL TABLE |#########
#########| to obtain the appropriate value of call_type for your |#########
#########| program. |#########
#########| -------------------------------------------------------- |#########
#########| The procedure installed by timer_entry() is not active |#########
#########| until either the tsr or the active_procs procedure is |#########
#########| invoked. A program may have more than one "timer" |#########
#########| procedure. |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 1 |-------------------------------------------+#########
#########| * Install a tsr clock. Prints the time in the |#########
#########| * upper left hand corner of the screen. |#########
#########| |#########
#########| #include tsr.hdr |#########
#########| PROCEDURE clock |#########
#########| VARDEF |#########
#########| INT r,c |#########
#########| ENDDEF |#########
#########| r = row() |#########
#########| c = col() |#########
#########| @ 0,68 ?? time() |#########
#########| @ r,c |#########
#########| ENDPRO |#########
#########| |#########
#########| PROCEDURE force_main |#########
#########| IF .NOT. timer_entry( clock, 1, &TSR_TIME_SEC, ; |#########
#########| &TSR_CALL_ANY) |#########
#########| ? "Unable to install clock." |#########
#########| ENDIF |#########
#########| |#########
#########| tsr(0) |#########
#########| ENDPRO |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 2 |-------------------------------------------+#########
#########| * Show the current record number, total records, |#########
#########| * etc in the bottom line of the screen. Update |#########
#########| * the display every 1/2 second. NOTE: Obviously, |#########
#########| * this will slow down processing. Turn off the |#########
#########| * display if necessary. |#########
#########| * also most clocks grab interrupts that could |#########
#########| * cause your modem to abort file transfers. |#########
#########| |#########
#########| VARDEF |#########
#########| LOGICAL display_on = .T. |#########
#########| ENDDEF |#########
#########| |#########
#########| PROCEDURE show_values |#########
#########| VARDEF |#########
#########| INT r,c |#########
#########| ENDDEF |#########
#########| IF .NOT. display_on |#########
#########| RETURN |#########
#########| ENDIF |#########
#########| |#########
#########| r = row() |#########
#########| c = col() |#########
#########| @ 0,24 ?? "Record #",recno(),"/",reccount() |#########
#########| @ r,c |#########
#########| ENDPRO |#########
#########| |#########
#########| {...} |#########
#########| timer_entry( show_values, 9, &TSR_TIME_TICKS, ; |#########
#########| &TSR_CALL_ANY) |#########
#########| activate_procs() && activate the display |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 3 |-------------------------------------------+#########
#########| * Install an automatic "download" utility that |#########
#########| * transfers files at 23:59 p.m. as a TSR program. |#########
#########| |#########
#########| #include tsr.hdr |#########
#########| #inlcude string.hdr |#########
#########| |#########
#########| PROCEDURE download |#########
#########| IF left( time(), 5 ) = "23:59" |#########
#########| DO download_files |#########
#########| ENDIF |#########
#########| ENDPRO |#########
#########| |#########
#########| PROCEDURE force_main |#########
#########| |#########
#########| timer_entry( download, 1, &TSR_TIME_MINS, ; |#########
#########| &TSR_CALL_DOS ) |#########
#########| tsr( 4096 ) |#########
#########| ENDPRO |#########
#########+----------------------------------------------------------+#########
##############################################################################
See Also:
activate_procs
tsr
tsr_install()
unload_tsr
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson