Metrologic IS1000 Series Guía de usuario Pagina 47

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 198
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 46
Chapter
5
BASIC
Commands
41
5.5 Commands for Event Trapping
An event is an action recognized by the terminal, such as a function keystroke is detected
(KEY event), a signal is received from the serial port (COM event), and so on. There are
two ways to detect the occurrence of an event and reroute the program control to an
appropriate subroutine: polling and trapping.
With event polling, the BASIC program explicitly checks for any event that happens at a
particular point in its execution. For example, the following statements cause the program
to loop back and forth until any key being pressed by the user:
Loop:
KeyData$ = INKEY$
IF KeyData$ = "" THEN GOTO Loop
...
Polling is useful when the occurrence of an event is predictable in the flow of the program.
But if the time of the occurrence of an event is not predictable, trapping becomes the better
alternative because the program will not be paused by the looping statements. For example,
the following statements cause the program rerouting to the Key_F1 subroutine when the
key F1 is pressed at anytime.
ON KEY(1) GOSUB Key_F1
...
Key_F1:
...
This section describes a variety of events that the BASIC can trap as well as the associated
commands.
5.5.1 Event Triggers
Below are 9 different events that can be trapped.
1 COM Event: a signal is received from the COM port.
2 ESC Event: the ESC key is pressed.
3 HOUR_SHARP Event: the system time is on the hour.
4 KEY Event: a function key is pressed.
5 MINUTE_SHARP Event: the system time is on the minute.
Vista de pagina 46
1 2 ... 42 43 44 45 46 47 48 49 50 51 52 ... 197 198

Comentarios a estos manuales

Sin comentarios