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

  1. *.............................................................................
  2. *
  3. *   Program Name: CTFACL00         Copyright: Magna Carta Software, Inc.
  4. *   Date Created: 11-17-91         Language: FoxPro v2.x
  5. *.............................................................................
  6. * Description: Sample Terminal Program. Based on FOXCOM00.PRG but
  7. * modified to support the Star Gate ACL intelligent multiport card.
  8. * See the "Application Note" in the CommTools manual for details.
  9. *.............................................................................
  10. CLEAR ALL
  11. SET TALK OFF
  12. SET ESCAPE OFF
  13.  
  14. * Load the right library
  15. foxid = VERS()
  16. IF "2.0" $ foxid
  17.     SET LIBR TO ctf                 && Identified FoxPro 2.0
  18. ELSE
  19.     IF "2.5" $ VERS()
  20.         IF "Windows" $ foxid        && Identified FoxPro 2.5 for Windows
  21.             SET LIBR TO ctfw
  22.         ELSE
  23.             SET LIBR TO ctf25       && Identified FoxPro 2.5 for DOS
  24.         ENDIF
  25.     ENDIF
  26. ENDIF
  27.  
  28. SET COLOR OF SCHEME 17 TO SCHEME 1  && save default color scheme
  29. SET COLOR OF SCHEME 18 TO SCHEME 2
  30.  
  31. DO ctfhdr
  32. DO ctfutil
  33. SET PROCEDURE TO CTFUTIL
  34.  
  35. version = 11
  36. portid  = 0
  37. ret = 0
  38.  
  39. ACTIVATE WINDOW w_status
  40. ACTIVATE WINDOW w_term
  41. =CT_SET_WIN(portid)
  42.  
  43. * Step 1: Initialize the board.
  44. *   INITIALIZE THE ACL ASSUMING AN I/O ADDRESS OF 200h AND DUAL PORT RAM
  45. *   ADDRESS OF D4000h (YOU CAN EDIT THESE TO SUIT).
  46. *   Note: The address MUST be specifed with the lowest twelve bits of the
  47. *   segment address equal to zero. E.g. C000, D000, etc. NOT CC00, DC00, etc.
  48. ret = acl_init(0, x2d("200"),  x2d("D000"), x2d("4000"))
  49. IF ret < 0
  50.     @00, 00 SAY "ACL initialization error -- check control program is loaded"
  51. ELSE
  52.     @00, 00 SAY "ACL board initialized"
  53. ENDIF
  54.  
  55. * Step2: WE ARE ONLY USING ONE CHANNEL. IT IS P1, BUT WE NUMBER THEM 0-7
  56. *   (0-15 ON 16-PORT CARDS).
  57. *   USE HIGH SPEED (38,400bps) TO SHOW THAT THE BOARD REALLY WORKS!
  58. *   Parameters:
  59. *       no. of port on board--¬
  60. *       boardID -----------¬  |
  61. *       portID ----¬       |  |
  62. ret = acl_init_channel(portid, 0, 0, 38400, 8, PARITY_NONE, 1)
  63. IF ret < 0
  64.     @01, 00 SAY "ACL channel initialization error"
  65. ELSE
  66.     @01, 00 SAY "ACL channel initialized"
  67. ENDIF
  68.  
  69.  
  70. DEFINE PAD p_ct_fsend  OF main_menu PROMPT "S\<end a File" AT 00, 37
  71.     ON SELECTION PAD p_ct_fsend  OF main_menu =do_file_send(portid, 37)
  72. DEFINE PAD p_ct_emul OF main_menu PROMPT "\<Terminal Emulation" AT 00, 50
  73.     ON SELECTION PAD p_ct_emul OF main_menu =do_term_emul(portid, 50)
  74.  
  75. ACTIVATE MENU main_menu
  76. @ 24,00 SAY "End of CommTools ACL Terminal Version " + LTRIM(STR(version))
  77.  
  78.  
  79.  
  80. *
  81. * GET_TERMINAL(expN tr, expN lc)
  82. * Show a menu that allows the user to select a terminal to emulate.
  83. * Called from do_terminal_menu()
  84. *
  85. FUNCTION get_terminal
  86.     PARAMETER col
  87.     PRIVATE termtype
  88.  
  89.     termtype = 0
  90.     DEFINE POPUP pop_terminal FROM 01, col;
  91.         IN SCREEN;
  92.         SHADOW
  93.         DEFINE BAR 1  OF pop_terminal PROMPT " \<TTY        "
  94.         DEFINE BAR 2  OF pop_terminal PROMPT " \<ANSI.SYS   "
  95.         DEFINE BAR 3  OF pop_terminal PROMPT " ANSI \<X3.64 "
  96.         DEFINE BAR 4  OF pop_terminal PROMPT " VT\<52       "
  97.         DEFINE BAR 5  OF pop_terminal PROMPT " VT\<100      "
  98.         DEFINE BAR 6  OF pop_terminal PROMPT " VT\<220      "
  99.  
  100.     ON SELECTION POPUP pop_terminal termtype=_terminal_menu(BAR())
  101.     ACTIVATE POPUP pop_terminal
  102.     DEACTIVATE POPUP pop_terminal
  103.     RELEASE POPUPS pop_terminal
  104. RETURN (termtype)
  105.  
  106.  
  107. FUNCTION _terminal_menu
  108.     PARAMETERS nChoice
  109.     PRIVATE termtype
  110.  
  111.     DO CASE
  112.         CASE nChoice = 1
  113.             termtype = TTY
  114.         CASE nChoice = 2
  115.             termtype = ANSI_SYS
  116.         CASE nChoice = 3
  117.             termtype = ANSI_X364
  118.         CASE nChoice = 4
  119.             termtype = DEC_VT52
  120.         CASE nChoice = 5
  121.             termtype = DEC_VT100
  122.         CASE nChoice = 6
  123.             termtype = DEC_VT220
  124.         OTHERWISE
  125.             termtype = CT_EOF
  126.     ENDCASE
  127.     =status_msg(0, "Terminal: " + ALLTRIM(PROMPT()))
  128. RETURN (termtype)
  129.  
  130.  
  131.  
  132. *
  133. * DO_TERM_EMUL(expN portid)
  134. * Show a menu that allows the user to select a terminal to emulate.
  135. * Called from mainmenu()
  136. *
  137. FUNCTION do_term_emul
  138.     PARAMETERS portid, col
  139.     PRIVATE termtype
  140.  
  141.     termtype = get_terminal(col)
  142.     IF termtype != CT_EOF
  143.         * USE XONXOFF FLOW CONTROL (THIS LETS US BUFFER RECEIVED DATA) *
  144.         =set_tx_xlat(portid, FLOWCTL, XONXOFF)   && better accept flow control if > 2400 bps
  145.         =set_rx_xlat(portid, LOCAL_ECHO, TRUE)   && echo RX data to screen
  146.         =set_tx_xlat(portid, LOCAL_ECHO, FALSE)  && (optionally) don't echo TX data
  147.         ret = term_init(0, termtype)
  148.         IF ret < 0
  149.             =status_msg(0, "Insufficient memory for terminal emulation")
  150.         ELSE
  151.             =term_set(portid, TERM_ROWS, WROWS("w_term")+1) && Must be interior height of window+1
  152. *           =term_set(portid, TERM_ROWS, 25)        && Won't work. Must be interior height of window+1
  153.             =term_set(portid, TERM_COLS, 78)
  154.             =term_set(portid, TERM_KEYCLICK, 0)     && Drives you mad!
  155.         ENDIF
  156.     ENDIF
  157. RETURN (ret)
  158.  
  159.  
  160.  
  161.  
  162. FUNCTION ct_online
  163.     PARAMETERS portid
  164.  
  165.     ACTIVATE WINDOW w_term
  166. *   =CT_SET_WIN(portid)
  167.     @ 00,00 SAY "CommTools ACL Terminal Version " +;
  168.         ALLTRIM(STR(version)) + ": Press CTRL-HOME for a list of commands"
  169.     =set_rx_xlat(portid, LOCAL_ECHO, TRUE)      && turn on RX echo
  170.     =set_tx_xlat(portid, FLOWCTL, XONXOFF)      && assert flow control
  171. *   =set_rx_xlat(portid, EOL, CR2CRLF)          && turn on TX EOL xlat
  172.  
  173.     =c_term(portid)                             && switch to terminal mode
  174. RETURN (0)
  175.  
  176.  
  177.  
  178. *
  179. * DO_MODEM_MENU(expN portid, expC number)
  180. * Show a menu that allows the user to send commands to the modem.
  181. *
  182. FUNCTION do_modem_menu
  183.     PARAMETERS portid, number, btr, blc
  184.     PUBLIC def_colors
  185.     PRIVATE nChoice, ret, scr, scr1, bbr, brc, motype
  186.  
  187.     DEFINE POPUP pop_modem FROM 01, col;
  188.         IN SCREEN;
  189.         SHADOW
  190.         DEFINE BAR 1  OF pop_modem PROMPT "Return"
  191.         DEFINE BAR 2  OF pop_modem PROMPT "Initilize"
  192.         DEFINE BAR 3  OF pop_modem PROMPT "Dial"
  193.  
  194. *   ON SELECTION POPUP pop_modem =_modem_menu(portid, VAL(PROMPT()))
  195.     ACTIVATE POPUP pop_modem
  196.     RELEASE pop_modem
  197. RETURN (0)
  198.  
  199.  
  200.  
  201. FUNCTION modem_menu
  202.     PARAMETERS portid, choice
  203.     PRIVATE ret
  204.  
  205.     MENU TO nChoice
  206.     DO CASE
  207.         CASE choice = 1
  208.             EXIT
  209.         CASE Choice = 2
  210.             motype = modem_type(portid)
  211.             ret = status_msg(0, "Modem Type is: " + STR(motype))
  212.             =INKEY(0)
  213.             =modem_init(portid, modem_type(portid))
  214.         CASE Choice = 3
  215.             ret=status_msg(0, "Dialing: " + LTRIM(number))
  216.             ret = modem_dial(portid, number)
  217.             @ 24, 00 SAY "Dial Return Code: " + STR(ret)
  218.             =INKEY(0)
  219.             IF ret < 0
  220.                 @24, 00 SAY "Modem not initialized            "
  221.                 =INKEY(0)
  222.             ELSE
  223.                 EXIT
  224.             ENDIF
  225.     ENDCASE
  226. RETURN (Choice)
  227.  
  228.  
  229.  
  230. *
  231. * C_TERM -- This is a dumb terminal loop in FoxPro.
  232. * Alternately poll the serial input buffer and the keyboard for data.
  233. *
  234. FUNCTION c_term
  235.     PARAMETERS portid
  236.     PRIVATE c
  237.  
  238.     ?
  239.     DO WHILE .T.
  240.         * CHECK SERIAL PORT FOR BYTE *
  241.         c = c_getc(portid)                      && check the serial port for a byte
  242.         * CHECK KEYBOARD FOR A KEY PRESS *
  243.         c = INKEY()                             && check keyboard for a key
  244.         DO CASE                                 && evaluate the received key
  245.             CASE c == 29                        && CTRL-HOME was pressed
  246.                 RETURN (0)
  247.             CASE c <> 0
  248.                 =c_putc(portid, c)
  249.         ENDCASE
  250.     ENDDO                                       && do while .t.
  251. RETURN (0)
  252.  
  253.  
  254.  
  255. *
  256. * DO_FILE_SEND(expN portid)
  257. * Show a menu to invoke file transmission.
  258. * Called from mainmenu()
  259. *
  260. FUNCTION do_file_send
  261.     PARAMETERS portid, col
  262.     PRIVATE fname, ret, old_screen
  263.  
  264.     ret   = -1
  265.     DO WHILE .T.
  266.         protocol = get_protocol(col)
  267.         IF protocol == 0
  268.             EXIT
  269.         ENDIF
  270.         fname = get_filnam(.T.)
  271.         IF LEN(fname) != 0
  272.             =save_xlat(0)
  273.             =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && optionally echo RX to screen
  274. *           =set_tx_xlat(portid, LOCAL_ECHO, TRUE) && optionally turn on TX local echo
  275.  
  276.             * USE XONXOFF FLOW CONTROL (THIS LETS THE RECEIVER WRITE TO DISK) *
  277.             IF protocol = ASCII
  278.                 =set_rx_xlat(portid, FLOWCTL, XONXOFF)   && better accept flow control if > 2400 bps
  279.             ENDIF
  280.             ret = fqueue(fname)
  281.             IF ret == 0
  282.                 =status_msg(0, "Sending: " + fname)
  283.                 ret = fsend(portid, protocol, NULL)    && send the file as ASCII
  284.                 =status_msg(0, "FINISHED!")
  285.             ELSE
  286.                 =status_msg(0, "File not found")
  287.             ENDIF
  288.         ENDIF
  289.     ENDDO
  290. RETURN (ret)
  291.