home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a081 / 2.ddi / CTFXX.EXE / FOXCOM00.PRG < prev    next >
Encoding:
Text File  |  1993-05-12  |  2.4 KB  |  73 lines

  1. *.............................................................................
  2. *   Program Name: FOXCOM00         Copyright: Magna Carta Software, Inc.
  3. *   Date Created: 06-21-91         Language: FoxPro v2.0
  4. *.............................................................................
  5. * Description: Sample Dumb-Terminal Program.
  6. * Terminal loop implemented in FoxPro
  7. * Uses polling -- not interrupts
  8. *.............................................................................
  9.  
  10. PUBLIC version, ret
  11. version = 0
  12.  
  13. CLEAR
  14. SET TALK OFF
  15. SET ESCAPE OFF
  16.  
  17. * Load the right library
  18. foxid = VERS()
  19. IF "2.0" $ foxid
  20.     SET LIBR TO ctf                 && Identified FoxPro 2.0
  21. ELSE
  22.     IF "2.5" $ VERS()
  23.         IF "Windows" $ foxid        && Identified FoxPro 2.5 for Windows
  24.             SET LIBR TO ctfw
  25.         ELSE
  26.             SET LIBR TO ctf25       && Identified FoxPro 2.5 for DOS
  27.         ENDIF
  28.     ENDIF
  29. ENDIF
  30.  
  31. DO ctfhdr                               && define & declare CommTools memvars
  32.  
  33. ret = u8250_init(0, COM1, 1200, 8, PARITY_NONE, 1) && initialize COM1 (I/O address = 1016)
  34. IF ret < 0
  35.     ? ret
  36.     =INKEY(0)
  37.     CANCEL
  38. ENDIF
  39. @ 00,00 SAY "CommTools Terminal Version " + LTRIM(STR(version)) + ": Press ESC to Exit"
  40. =c_term(0)                                && switch to dumb terminal mode
  41. =deinit_port(0)                           && deinitialize the port
  42. CLEAR
  43. @ 24,00 SAY "End of CommTools Terminal Version " + LTRIM(STR(version))
  44. RETURN
  45.  
  46.  
  47. *
  48. * C_TERM -- This is a dumb terminal loop in FoxPro
  49. * Alternately poll the serial input buffer and the keyboard for data.
  50. *
  51. PROCEDURE c_term
  52.     PARAMETERS portid
  53.     PRIVATE c
  54.  
  55.     ?
  56.     DO WHILE .T.
  57.         * CHECK SERIAL PORT FOR BYTE *
  58.         c = c_getc(portid)                    && check the serial port for a byte
  59.         IF c <> CT_EOF                              && if a valid character display it
  60.             ?? CHR(c)
  61.         ENDIF
  62.         * CHECK KEYBOARD FOR A KEY PRESS *
  63.         c = INKEY()                             && check keyboard for a key
  64.         DO CASE                                 && evaluate the received key
  65.             CASE c == ESC                        && ESC was pressed
  66.                 RETURN
  67.             CASE c <> 0
  68.                 =c_putc(portid, c)
  69.         ENDCASE
  70.     ENDDO                                       && do while .t.
  71.     @02,00 SAY "Exiting c_term()"
  72. RETURN
  73.