In order for this site to work correctly, and for us to improve the site, we need to store a small file (called a cookie) on your computer.
By continuing to use this website, you agree to our cookies and privacy policy.
  
Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel

Esc.To.Exit

On the RevTech BBS a few months ago, one of the users asked the question, "how do I check to see if an <esc> key has been pressed without losing what was already in the input buffer ?". In other words, if I am in a lengthy processing loop from which the user ought to be able to escape by pressing <esc>, how do I allow this facility but still allow them to type ahead ?" As this query was never answered I have taken the liberty of using this query as an entry point to the discussion of ESC.TO.EXIT.

Fortunately for the inquisitive developer, RevTech use meaningful names for most of their subroutines (with the possible execption of the Verbs, the RTPs and FAT.FINGER (see later)) so studying the VERBS file provided the answer, a routine called ESC.TO.EXIT. This is a function which, called from a processing loop, returns true if <esc> was pressed and false if it was not. However any keys awaiting processing whilst ESC.TO.EXIT was being called, would be left in the data buffer. To illustrate this try the following section of code.


0001      DECLARE FUNCTION ESC.TO.EXIT
0002      EQU TRUE$    TO 1
0003      EQU FALSE$   TO 0
0004      *
0005      * Set a time for the loop to repeat
0006      *
0007      END.LOOP = TIME() + 4
0008      USER.ESCAPED = FALSE$
0009      LOOP
0010         *
0011         * Insert processing loop here
0012         *
0013      UNTIL TIME() > END.LOOP OR USER.ESCAPED
0014         IF ESC.TO.EXIT() THEN USER.ESCAPED = TRUE$
0015      REPEAT
0016      IF USER.ESCAPED THEN
0017         CALL MSG("<Esc> key pressed", "", "", "")
0018      END ELSE
0019         *
0020         * Now build a string to show what has been buffered in the data
0021         * statement
0022         *
0023         NEW = ""
0024         LOOP
0025            INPUT X,-1
0026         WHILE X DO
0027            NEW := X
0028         REPEAT
0029         CALL MSG(NEW : " entered", "", "", "")
0030      END

It is apparent from the above description that when using the ESC.TO.EXIT() function, the user is not restricted to the standard keyboard buffer (the data entered being appended to the DATA statement not stored in the keyboard buffer). Thus using this method the user could type ahead up to a maximum of 64K. This is either an advantage or a disadvantage depending upon your trusting your users to know what they are typing after 15 keystrokes !

(Volume 1, Issue 9, Page 9)
Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel