home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / TERMINAL.BA$ / TERMINAL.bin
Encoding:
Text File  |  1990-06-24  |  1.9 KB  |  75 lines

  1. DEFINT A-Z
  2.  
  3. DECLARE    SUB Filter (InString$)
  4.  
  5. COLOR 7, 1            ' Set screen color.
  6. CLS
  7.  
  8. Quit$ = CHR$(0) + CHR$(16)    ' Value returned by INKEY$
  9.                 ' when ALT+q is pressed.
  10.  
  11. ' Set up prompt on bottom line of screen and turn cursor on:
  12. LOCATE 24, 1, 1
  13. PRINT STRING$(80, "_");
  14. LOCATE 25, 1
  15. PRINT TAB(30); "Press ALT+q to quit";
  16.  
  17. VIEW PRINT 1 TO    23        ' Print between lines 1 & 23.
  18.  
  19. ' Open communications (1200 baud, no parity, 8-bit data,
  20. ' 1 stop bit, 256-byte input buffer):
  21. OPEN "COM1:1200,N,8,1" FOR RANDOM AS #1    LEN = 256
  22.  
  23. DO                ' Main communications loop.
  24.  
  25.    KeyInput$ = INKEY$        ' Check the keyboard.
  26.  
  27.    IF KeyInput$    = Quit$    THEN    ' Exit the loop if the user
  28.       EXIT DO            ' pressed ALT+q.
  29.  
  30.    ELSEIF KeyInput$ <> "" THEN    ' Otherwise, if the user has
  31.       PRINT #1,    KeyInput$;    ' pressed a key, send the
  32.    END IF            ' character typed to modem.
  33.  ' Check the modem. If characters are waiting (EOF(1) is
  34.  ' true), get them and print them to the screen:
  35.  IF NOT EOF(1) THEN
  36.  
  37.       ' LOC(1) gives the number of characters waiting:
  38.       ModemInput$ = INPUT$(LOC(1), #1)
  39.  
  40.       Filter ModemInput$    ' Filter out line feeds and
  41.       PRINT ModemInput$;    ' backspaces, then print.
  42.    END IF
  43. LOOP
  44.  
  45. CLOSE                ' End communications.
  46. CLS
  47. END
  48. '
  49. ' ========================= FILTER ========================
  50. '               Filters characters in an input string
  51. ' =========================================================
  52. '
  53. SUB Filter (InString$) STATIC
  54.  
  55.    ' Look for backspace characters and recode
  56.    ' them to CHR$(29) (the LEFT cursor key):
  57.    DO
  58.       BackSpace = INSTR(InString$, CHR$(8))
  59.       IF BackSpace THEN
  60.       MID$(InString$, BackSpace) = CHR$(29)
  61.       END IF
  62.    LOOP WHILE BackSpace
  63.  
  64.    ' Look for line-feed characters and
  65.    ' remove any found:
  66.    DO
  67.       LnFd = INSTR(InString$, CHR$(10))
  68.       IF LnFd THEN
  69.    InString$=LEFT$(InString$,LnFd-1)+MID$(InString$,LnFd+1)
  70.       END IF
  71.    LOOP WHILE LnFd
  72.  
  73. END SUB
  74.  
  75.