home *** CD-ROM | disk | FTP | other *** search
- *.............................................................................
- * Program Name: FOXCOM11 Copyright: Magna Carta Software, Inc.
- * Date Created: 10-03-91 Language: FoxPro 2.x
- *.............................................................................
- * Description: Sample Terminal Program. Based on FOXCOM10.PRG plus...
- * Terminal Emulation.
- *.............................................................................
- 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
-
- ACTIVATE WINDOW w_status
- ACTIVATE WINDOW w_term
-
- ret = u8250_init(portid, COM1, 2400, 8, PARITY_NONE, 1)
- IF ret < 0
- ? ret
- =INKEY(0)
- CANCEL
- ENDIF
- =CT_SET_WIN(portid)
-
- ret =install_ipr(portid, RECEIVE, NULL, 1024)
- IF ret < 0
- ? ret-1
- =INKEY(0)
- CANCEL
- ENDIF
- ret =install_ipr(portid, TRANSMIT, NULL, 4096)
- IF ret < 0
- ? ret-1
- =INKEY(0)
- CANCEL
- ENDIF
- ret =install_isr(portid, 4, NULL) && IRQ4 (use 3 for COM2)
- IF ret < 0
- ? ret-2
- =INKEY(0)
- CANCEL
- ENDIF
-
-
- PUBLIC fh && declare our file handle
-
- IF ret == 0
- =set_rx_xlat(portid, LOCAL_ECHO, TRUE) && turn on RX echo
- fh = FCREATE("mylog.log", 0) && create log file
- ENDIF
-
- DEFINE PAD p_ct_emul OF main_menu PROMPT "\<Emulation" AT 00, 37
- ON SELECTION PAD p_ct_emul OF main_menu =do_term_emul(portid, 37)
-
- ACTIVATE MENU main_menu
-
- FUNCTION do_echo
- PARAMETERS ch
- =FWRITE(fh, ch)
- RETURN (NIL)
-
-
-
- *
- * 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 nChoice, 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(portid, termtype)
- =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!
- IF ret < 0
- =status_msg(0, "Insufficient memory for terminal emulation")
- ENDIF
- ENDIF
- RETURN (ret)
-
-
-
- *
- * 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)
-
-
-
- FUNCTION ct_online
- PARAMETERS portid
-
- ACTIVATE WINDOW w_term
- @ 00,00 SAY "CommTools Terminal Version " +;
- ALLTRIM(STR(version)) + ": Press CTRL-HOME to return to menu"
-
- * =CT_SET_WIN(portid)
- =set_rx_xlat(portid, FILE_ECHO, "DO_ECHO") && turn on file echo
- =c_term(portid) && switch to dumb terminal mode
- RETURN (0)
-
-
-
- *
- * 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 *
- * THE GRAND COMPROMISE...
- * INKEY() IS SLOW, SO AVOID IT
- * CHRSAW() DOES NOT DISPLAY THE CURSOR, SO CALL INKEY() PERIODICALLY
- IF c == CT_EOF .OR. CHRSAW() == .T.
- c = INKEY() && check keyboard for a key
- DO CASE && evaluate the received key
- CASE c == 29 && CTRL-HOME was pressed
- RETURN (0)
- CASE c == DEL
- =c_putc(portid, BS) && Fox Does not handle back space nicely
- CASE c <> 0
- =c_putc(portid, c)
- ENDCASE
- ENDIF
- ENDDO && do while .t.
- RETURN (0)
-