home *** CD-ROM | disk | FTP | other *** search
- 'Reference Manual Example Page 79
- CLS
- 'Set up trap for processing COM input
- ON COM(1) GOSUB GetComInput
-
- 'Allocate a 5K array to store input
- DIM ComPortInput$( 5*1024 )
-
- 'Allocate head and tail pointers
- HeadPtr% = 0 : TailPtr% = 0
- COM(1) ON 'turn COM input trapping on
- $COM 1024 'set up 1K input buffer
- OPEN "COM1:" AS #1 'open COM1 with all default settings
- PRINT "Press any key to terminate the program..."
- WHILE NOT INSTAT 'if buffer isn't empty, display input
- IF TailPtr% <> HeadPtr% THEN
- PRINT "COM Port input: "; COMPortInput$( TailPtr% )
- TailPtr% = TailPtr% + 1 'step to next spot in buffer
- END IF
- LOCATE 2,1 : PRINT TIME$
- WEND
- CLOSE
- END
-
- 'Routine to COM port interrupt
- GetCOMInput:
- 'Read a line of input from COM port buffer
- INPUT #1, COMPortInput$(HeadPtr%)
- HeadPtr% = HeadPtr% + 1 'advance buffer pointer
- RETURN