bas7ex.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 Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the WAIT statement to suspend program execution while
'monitioring the status of COM1.
 
'Note: To run this program, you must have an ASCII terminal connected to
'COM1 at 9600 baud, 8 data bits, 1 stop bit, and no parity.
 
CLS
'Open and close the port at the proper baud rate.
OPEN "COM1:9600,N,8,1,BIN" FOR RANDOM AS #1
CLOSE #1
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
    'Get a character from the port.
    A% = INP(PortNum%)
    'Evaluate the character.
    SELECT CASE A%
        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
    'Report the input character.
    PRINT "Numeric Value                    ASCII Character"
    LOCATE 14, 20
    PRINT A%; TAB(50); Character$
    IF A% > 127 THEN STOP
    LOCATE 23, 25
    PRINT "Press ANY key to quit."
LOOP WHILE INKEY$ = ""
END