home *** CD-ROM | disk | FTP | other *** search
- *.............................................................................
- * Program Name: FOXCOM10 Copyright: Magna Carta Software, Inc.
- * Date Created: 10-03-91 Language: FoxPro 2.x
- *.............................................................................
- * Description: Sample Terminal Program. Based on FOXCOM09.PRG plus...
- * File receive, with error correction, using any of XMODEM, XMODEM-CRC,
- * XMODEM-1k YMODEM, YMODEM-g, or ZMODEM
- *.............................................................................
- 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
- number = "720-9183"
- portid = 0
- version = 10
-
- ACTIVATE WINDOW w_status
- ACTIVATE WINDOW w_term
-
- ret = u8250_init(portid, x2d("2e8"), 19200, 8, PARITY_NONE, 1)
- IF ret < 0
- ? ret
- =INKEY(0)
- CANCEL
- ENDIF
- =CT_SET_WIN(portid)
-
- ret =install_ipr(portid, RECEIVE, NULL, 2048)
- IF ret < 0
- ? ret-1
- =INKEY(0)
- CANCEL
- ENDIF
- ret =install_ipr(portid, TRANSMIT, NULL, 4*1024)
- IF ret < 0
- ? ret-1
- =INKEY(0)
- CANCEL
- ENDIF
- ret =install_isr(portid, 5, NULL) && IRQ4 (use 3 for COM2)
- IF ret < 0
- ? ret-2
- =INKEY(0)
- CANCEL
- ENDIF
-
- IF ret == 0
- =set_rx_xlat(0, LOCAL_ECHO, TRUE) && turn on RX echo
- * =set_rx_xlat(0, EOL, CR2CRLF) && turn on RX echo
- ENDIF
-
- DEFINE PAD p_ct_modem OF main_menu PROMPT "\<Modem Command" AT 00, 37
- ON SELECTION PAD p_ct_modem OF main_menu DO ct_modem WITH portid, 37 IN CTFMODEM.PRG
-
- DEFINE PAD p_ct_fsend OF main_menu PROMPT "S\<end a File" AT 00, 52
- ON SELECTION PAD p_ct_fsend OF main_menu =do_file_send(portid, 52)
-
- DEFINE PAD p_ct_freceive OF main_menu PROMPT "\<Receive File" AT 00, 65
- ON SELECTION PAD p_ct_freceive OF main_menu =do_file_receive(portid, 65)
-
- ACTIVATE MENU main_menu
-
-
-
- FUNCTION ct_online
- PARAMETERS portid
-
- =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
-
- ACTIVATE WINDOW w_term
- @ 00,00 SAY "CommTools Terminal Version " +;
- ALLTRIM(STR(version)) + ": Press CTRL-HOME to return to menu"
- ?
-
- 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 && CTL-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
- ENDDO && do while .t.
- RETURN (0)
-
-
-
- *
- * DO_FILE_RECEIVE(expN portid)
- * Show a menu to invoke file transmission.
- * Called from mainmenu()
- *
- FUNCTION do_file_receive
- PARAMETERS portid, col
- PRIVATE fname, fsize, ret, protocol
-
- ret = -1
- fsize = 0
- DO WHILE .T.
- protocol = get_protocol(col)
- IF protocol == 0
- EXIT
- ENDIF
- IF protocol == KERMIT .OR. protocol == YMODEM;
- .OR. protocol == ZMODEM .OR. protocol == YMODEM_G
- fname = " "
- ELSE
- fname = get_filnam(.F.)
- ENDIF
- IF LEN(fname) != 0
- =save_xlat(portid)
- =set_rx_xlat(portid, LOCAL_ECHO, FALSE) && optionally turn off RX local echo
- =set_tx_xlat(portid, LOCAL_ECHO, FALSE) && optionally don't echo TX data
-
- * 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
- =set_rx_xlat(portid, INTERBYTE_DELAY, 5000) && set interbyte delay to 5000 ms.
- ENDIF
- * Define a Window to show file transfer status reports.
- * Note that the status window could be used for file transfer status
- * reports instead.
- =display_xfer(5, 5, fname, fsize)
- * RECEIVE STARTS HERE (buffer size may be adjusted)
- ret = freceive(portid, protocol, 6*1024, "xfer_progress")
- * ret = freceive(portid, protocol, 4096, NULL) && no progress reporting
- =status_msg(0, STR(ret))
- =SOUND_ON(100, 500)
- DEACTIVATE WINDOW w_xfer
- =status_msg(0, "FINISHED")
- IF protocol = ASCII
- COPY FILE "TEMP0000.$$$" TO fname
- ENDIF
- DEACTIVATE WINDOW w_xfer
- =restore_xlat(portid)
- ELSE
- =status_msg(0, "File not found")
- ENDIF
- ENDDO
- RETURN (ret)
-
-
-
- *
- * 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
-
- ret = -1
- DO WHILE .T.
- protocol = get_protocol(52)
- IF protocol == 0
- EXIT
- ENDIF
- FOR i = 0 TO 10
- fname = get_filnam(.T.)
- IF LEN(fname) != 0
- ret = fqueue(fname)
- IF ret != 0
- EXIT
- ENDIF
- IF protocol == ASCII .OR. protocol == XMODEM .OR. ;
- protocol == XMODEM_CRC .OR. protocol == XMODEM_1K
- EXIT
- ENDIF
- ELSE
- EXIT
- ENDIF
- NEXT
- IF ret == 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
- fsize = NULL
- * =status_msg(0, "Sending: " + fname) && use this for status window
- =display_xfer(5, 5, fname, fsize)
- ret = fsend(portid, protocol, 4*1024, "xfer_progress") && send the file as ASCII
- =INKEY(0.5)
- DEACTIVATE WINDOW w_xfer
- =status_msg(0, "FINISHED!")
- =restore_xlat(0)
- ENDIF
- ENDDO
- RETURN (ret)
-