home *** CD-ROM | disk | FTP | other *** search
- *.............................................................................
- *
- * Program Name: CTFACL00 Copyright: Magna Carta Software, Inc.
- * Date Created: 11-17-91 Language: FoxPro v2.x
- *.............................................................................
- * Description: Sample Terminal Program. Based on FOXCOM00.PRG but
- * modified to support the Star Gate ACL intelligent multiport card.
- * See the "Application Note" in the CommTools manual for details.
- *.............................................................................
- CLEAR ALL
- SET TALK OFF
- SET ESCAPE OFF
-
- * Load the right library
- foxid = VERS()
- IF "2.0" $ foxid
- SET LIBR TO ctf && Identified FoxPro 2.0
- ELSE
- IF "2.5" $ VERS()
- IF "Windows" $ foxid && Identified FoxPro 2.5 for Windows
- SET LIBR TO ctfw
- ELSE
- SET LIBR TO ctf25 && Identified FoxPro 2.5 for DOS
- ENDIF
- ENDIF
- ENDIF
-
- SET COLOR OF SCHEME 17 TO SCHEME 1 && save default color scheme
- SET COLOR OF SCHEME 18 TO SCHEME 2
-
- DO ctfhdr
- DO ctfutil
- SET PROCEDURE TO CTFUTIL
-
- version = 11
- portid = 0
- ret = 0
-
- ACTIVATE WINDOW w_status
- ACTIVATE WINDOW w_term
- =CT_SET_WIN(portid)
-
- * Step 1: Initialize the board.
- * INITIALIZE THE ACL ASSUMING AN I/O ADDRESS OF 200h AND DUAL PORT RAM
- * ADDRESS OF D4000h (YOU CAN EDIT THESE TO SUIT).
- * Note: The address MUST be specifed with the lowest twelve bits of the
- * segment address equal to zero. E.g. C000, D000, etc. NOT CC00, DC00, etc.
- ret = acl_init(0, x2d("200"), x2d("D000"), x2d("4000"))
- IF ret < 0
- @00, 00 SAY "ACL initialization error -- check control program is loaded"
- ELSE
- @00, 00 SAY "ACL board initialized"
- ENDIF
-
- * Step2: WE ARE ONLY USING ONE CHANNEL. IT IS P1, BUT WE NUMBER THEM 0-7
- * (0-15 ON 16-PORT CARDS).
- * USE HIGH SPEED (38,400bps) TO SHOW THAT THE BOARD REALLY WORKS!
- * Parameters:
- * no. of port on board--¬
- * boardID -----------¬ |
- * portID ----¬ | |
- ret = acl_init_channel(portid, 0, 0, 38400, 8, PARITY_NONE, 1)
- IF ret < 0
- @01, 00 SAY "ACL channel initialization error"
- ELSE
- @01, 00 SAY "ACL channel initialized"
- ENDIF
-
-
- DEFINE PAD p_ct_fsend OF main_menu PROMPT "S\<end a File" AT 00, 37
- ON SELECTION PAD p_ct_fsend OF main_menu =do_file_send(portid, 37)
- DEFINE PAD p_ct_emul OF main_menu PROMPT "\<Terminal Emulation" AT 00, 50
- ON SELECTION PAD p_ct_emul OF main_menu =do_term_emul(portid, 50)
-
- ACTIVATE MENU main_menu
- @ 24,00 SAY "End of CommTools ACL Terminal Version " + LTRIM(STR(version))
-
-
-
- *
- * GET_TERMINAL(expN tr, expN lc)
- * Show a menu that allows the user to select a terminal to emulate.
- * Called from do_terminal_menu()
- *
- FUNCTION get_terminal
- PARAMETER col
- PRIVATE termtype
-
- termtype = 0
- DEFINE POPUP pop_terminal FROM 01, col;
- IN SCREEN;
- SHADOW
- DEFINE BAR 1 OF pop_terminal PROMPT " \<TTY "
- DEFINE BAR 2 OF pop_terminal PROMPT " \<ANSI.SYS "
- DEFINE BAR 3 OF pop_terminal PROMPT " ANSI \<X3.64 "
- DEFINE BAR 4 OF pop_terminal PROMPT " VT\<52 "
- DEFINE BAR 5 OF pop_terminal PROMPT " VT\<100 "
- DEFINE BAR 6 OF pop_terminal PROMPT " VT\<220 "
-
- ON SELECTION POPUP pop_terminal termtype=_terminal_menu(BAR())
- ACTIVATE POPUP pop_terminal
- DEACTIVATE POPUP pop_terminal
- RELEASE POPUPS pop_terminal
- RETURN (termtype)
-
-
- FUNCTION _terminal_menu
- PARAMETERS nChoice
- PRIVATE termtype
-
- DO CASE
- CASE nChoice = 1
- termtype = TTY
- CASE nChoice = 2
- termtype = ANSI_SYS
- CASE nChoice = 3
- termtype = ANSI_X364
- CASE nChoice = 4
- termtype = DEC_VT52
- CASE nChoice = 5
- termtype = DEC_VT100
- CASE nChoice = 6
- termtype = DEC_VT220
- OTHERWISE
- termtype = CT_EOF
- ENDCASE
- =status_msg(0, "Terminal: " + ALLTRIM(PROMPT()))
- RETURN (termtype)
-
-
-
- *
- * DO_TERM_EMUL(expN portid)
- * Show a menu that allows the user to select a terminal to emulate.
- * Called from mainmenu()
- *
- FUNCTION do_term_emul
- PARAMETERS portid, col
- PRIVATE termtype
-
- termtype = get_terminal(col)
- IF termtype != CT_EOF
- * USE XONXOFF FLOW CONTROL (THIS LETS US BUFFER RECEIVED DATA) *
- =set_tx_xlat(portid, FLOWCTL, XONXOFF) && better accept flow control if > 2400 bps
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && echo RX data to screen
- =set_tx_xlat(portid, LOCAL_ECHO, FALSE) && (optionally) don't echo TX data
- ret = term_init(0, termtype)
- IF ret < 0
- =status_msg(0, "Insufficient memory for terminal emulation")
- ELSE
- =term_set(portid, TERM_ROWS, WROWS("w_term")+1) && Must be interior height of window+1
- * =term_set(portid, TERM_ROWS, 25) && Won't work. Must be interior height of window+1
- =term_set(portid, TERM_COLS, 78)
- =term_set(portid, TERM_KEYCLICK, 0) && Drives you mad!
- ENDIF
- ENDIF
- RETURN (ret)
-
-
-
-
- FUNCTION ct_online
- PARAMETERS portid
-
- ACTIVATE WINDOW w_term
- * =CT_SET_WIN(portid)
- @ 00,00 SAY "CommTools ACL Terminal Version " +;
- ALLTRIM(STR(version)) + ": Press CTRL-HOME for a list of commands"
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && turn on RX echo
- =set_tx_xlat(portid, FLOWCTL, XONXOFF) && assert flow control
- * =set_rx_xlat(portid, EOL, CR2CRLF) && turn on TX EOL xlat
-
- =c_term(portid) && switch to terminal mode
- RETURN (0)
-
-
-
- *
- * DO_MODEM_MENU(expN portid, expC number)
- * Show a menu that allows the user to send commands to the modem.
- *
- FUNCTION do_modem_menu
- PARAMETERS portid, number, btr, blc
- PUBLIC def_colors
- PRIVATE nChoice, ret, scr, scr1, bbr, brc, motype
-
- DEFINE POPUP pop_modem FROM 01, col;
- IN SCREEN;
- SHADOW
- DEFINE BAR 1 OF pop_modem PROMPT "Return"
- DEFINE BAR 2 OF pop_modem PROMPT "Initilize"
- DEFINE BAR 3 OF pop_modem PROMPT "Dial"
-
- * ON SELECTION POPUP pop_modem =_modem_menu(portid, VAL(PROMPT()))
- ACTIVATE POPUP pop_modem
- RELEASE pop_modem
- RETURN (0)
-
-
-
- FUNCTION modem_menu
- PARAMETERS portid, choice
- PRIVATE ret
-
- MENU TO nChoice
- DO CASE
- CASE choice = 1
- EXIT
- CASE Choice = 2
- motype = modem_type(portid)
- ret = status_msg(0, "Modem Type is: " + STR(motype))
- =INKEY(0)
- =modem_init(portid, modem_type(portid))
- CASE Choice = 3
- ret=status_msg(0, "Dialing: " + LTRIM(number))
- ret = modem_dial(portid, number)
- @ 24, 00 SAY "Dial Return Code: " + STR(ret)
- =INKEY(0)
- IF ret < 0
- @24, 00 SAY "Modem not initialized "
- =INKEY(0)
- ELSE
- EXIT
- ENDIF
- ENDCASE
- RETURN (Choice)
-
-
-
- *
- * C_TERM -- This is a dumb terminal loop in FoxPro.
- * Alternately poll the serial input buffer and the keyboard for data.
- *
- FUNCTION c_term
- PARAMETERS portid
- PRIVATE c
-
- ?
- DO WHILE .T.
- * CHECK SERIAL PORT FOR BYTE *
- c = c_getc(portid) && check the serial port for a byte
- * CHECK KEYBOARD FOR A KEY PRESS *
- c = INKEY() && check keyboard for a key
- DO CASE && evaluate the received key
- CASE c == 29 && CTRL-HOME was pressed
- RETURN (0)
- CASE c <> 0
- =c_putc(portid, c)
- ENDCASE
- ENDDO && do while .t.
- RETURN (0)
-
-
-
- *
- * DO_FILE_SEND(expN portid)
- * Show a menu to invoke file transmission.
- * Called from mainmenu()
- *
- FUNCTION do_file_send
- PARAMETERS portid, col
- PRIVATE fname, ret, old_screen
-
- ret = -1
- DO WHILE .T.
- protocol = get_protocol(col)
- IF protocol == 0
- EXIT
- ENDIF
- fname = get_filnam(.T.)
- IF LEN(fname) != 0
- =save_xlat(0)
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && optionally echo RX to screen
- * =set_tx_xlat(portid, LOCAL_ECHO, TRUE) && optionally turn on TX local echo
-
- * USE XONXOFF FLOW CONTROL (THIS LETS THE RECEIVER WRITE TO DISK) *
- IF protocol = ASCII
- =set_rx_xlat(portid, FLOWCTL, XONXOFF) && better accept flow control if > 2400 bps
- ENDIF
- ret = fqueue(fname)
- IF ret == 0
- =status_msg(0, "Sending: " + fname)
- ret = fsend(portid, protocol, NULL) && send the file as ASCII
- =status_msg(0, "FINISHED!")
- ELSE
- =status_msg(0, "File not found")
- ENDIF
- ENDIF
- ENDDO
- RETURN (ret)
-