' simple terminal program example ' Set the size of the input comm buffer $com 2048 ' Clear the screen, and ask user to enter appropriate bps rate ' Program won't respond until answer is in the range "a"-"e". cls print print " a) 300 d) 9600" print " b) 1200 e) 19200" print " c) 2400" print print " Which bps rate? (a-e) "; do key2$=lcase$(inkey$) loop until asc(key2$)>96 and asc(key2$)<102 print key2$ if key2$="a" then bd$="300" if key2$="b" then bd$="1200" if key2$="c" then bd$="2400" if key2$="d" then bd$="9600" if key2$="e" then bd$="19200" ' Open the RS232 link at 1200 bps. Note that the option "rs" is not used. ' Line powered modems occasionally "feed" off the RTS line. Some line ' powered modems also "feed" off the DTR line, which is turned on as ' soon as the open command is executed. So, execute it early. filenm$="com1:"+bd$+",n,8,1,ds,cs,cd" open filenm$ as #1 ' Begin the I/O loop. Loop continues until user presses the ESC key. ' Every incoming RS232 char is filtered with a logical AND, to remove ' the 8th bit. This allows the program to "not care" what the bits ' and parity are, for incoming text. Simple xon/xoff flow control is ' supported, if the buffer begins to fill at high bps rates. xoff%=0 do buf%=loc(1) : 'how much is in the buffer? if buf%>1024 then : 'if buffer is half full send XOFF print #1,chr$(19) xoff%=1 end if for in%=1 to buf% : 'empty buffer contents key$=input$(1,#1) AND 127 print key$; next in% if xoff%=1 then : 'if XOFF was sent, now send XON print #1,chr$(17) xoff%=0 end if if instat<>0 then : 'check for key press key2$=inkey$ if asc(key2$)>31 then print #1,key2$; end if loop until asc(key2$)=27 : 'exit if ESC was pressed ' Close the file (which drops DTR and forces disconnect if the modem ' is set up right) and return to DOS. The close statement can be ' skipped if desired, since the end statement automatically closes ' all files. close #1 end