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

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