ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
WAIT Statement Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the WAIT statement to suspend program execution while
' monitoring the status of COM1.
 
' Note: To run this example, you must have an ASCII terminal connected to
' COM1 at 9600 baud, 8 data bits, 1 stop bit, and no parity.
 
 CLS                                             ' Clear the screen
 
 OPEN "COM1:9600,N,8,1,BIN" FOR RANDOM AS #1     ' Open and close the port
 CLOSE #1                                        ' at the proper baud rate
 PortNum% = &H3F8 'COM1
 NonPrintCharMask% = 96
 
' Wait until there's some activity on COM1.
' Mask out characters less than 32 for the first input character.
 LOCATE 12, 15: PRINT "Waiting for a printable input character. "
 WAIT PortNum%, NonPrintCharMask%
 
' Once a printable character comes in, accept all characters.
 DO
     A% = INP(PortNum%)                 ' Get a character from the port
     SELECT CASE A%                     ' Evaluate the character
          CASE 7
               Character$ = "   BELL    "
          CASE 8
               Character$ = "BACK SPACE "
          CASE 9
               Character$ = "    TAB    "
          CASE 13
               Character$ = "    CR     "
          CASE 32
               Character$ = "   SPACE   "
          CASE 127
               Character$ = "    DEL    "
          CASE IS < 31, IS > 127
               Character$ = "unprintable"
          CASE ELSE
               Character$ = SPACE$(5) + CHR$(A%) + SPACE$(5)
     END SELECT
     LOCATE 12, 15
 
     PRINT "Numeric Value                    ASCII Character"
     LOCATE 14, 20
     PRINT A%; TAB(50); Character$      ' Report the input character
     IF A% > 127 THEN STOP
     LOCATE 23, 25
     PRINT "Press ANY key to quit."
 LOOP WHILE INKEY$ = ""
 END