G'Day All
Quote:
>Subject: Anyone have a qbasic or basica Terminal Program ????
>Date: Sun, 12 May 1996 23:17:27 GMT
>Hello,
>I and a group of hams (amateur radio ops) are looking for a basic
>language terminal program to use with packet radio. If you have one
>and it can be most any type of basic, I sure would appreciate it, if
>you would be so kind as to email it to me 8-)
>Any type of terminal program will be acceptable 8-)
Here is a little dumb terminal that I have posted before, but probably bears
reposting. It can open coms 1-4 up to enormous speeds. Unfortunately, all the
clever code is someone elses (documented in the prog).
The code is optimised for a device, rather than a modem, if you are using a
modem, you may want to remove the CS,DS items to enable handshaking.
'==========myterm.bas=======================================
DEFINT A-Z
DECLARE SUB Filter (InString$)
DECLARE SUB OPENCOM (InString$)
COLOR 7, 1 ' Set screen color.
CLS
Quit$ = CHR$(0) + CHR$(16) ' Value returned by INKEY$
' when ALT+q is pressed.
' Set up prompt on bottom line of screen and turn cursor on:
LOCATE 24, 1, 1
PRINT STRING$(80, "_");
LOCATE 25, 1
PRINT TAB(30); "Press ALT+q to quit";
VIEW PRINT 1 TO 23 ' Print between lines 1 & 23.
' Open communications (4800 baud, no parity, 8-bit data,
' 1 stop bit, 256-byte input buffer):
'Normal Basic open COM
'OPEN "COM2:4800,N,8,1,CS,DS,CD4000" FOR RANDOM AS #1 LEN = 256
'============================================================
'OPENCOM sub for high buad rates and access to coms 1-4
CALL OPENCOM("COM2:4800,N,8,1,CS,DS,CD4000 AS 1")
DO ' Main communications loop.
KeyInput$ = INKEY$ ' Check the keyboard.
IF KeyInput$ = Quit$ THEN ' Exit the loop if the user
EXIT DO ' pressed ALT+q.
ELSEIF KeyInput$ <> "" THEN ' Otherwise, if the user has
PRINT KeyInput$;
PRINT #1, KeyInput$; ' pressed a key, send the
END IF ' character typed to the modem.
' Check the modem. If characters are waiting (EOF(1) is
' true), get them and print them to the screen:
IF NOT EOF(1) THEN
' LOC(1) gives the number of characters waiting:
ModemInput$ = INPUT$(LOC(1), #1)
Filter ModemInput$ ' Filter out line feeds and
PRINT ModemInput$; ' backspaces, then print.
END IF
LOOP
CLOSE ' End communications.
CLS
END
'
' ========================= FILTER ==========================
' Filters characters in an input string.
' ============================================================
'
SUB Filter (InString$) STATIC
' Look for backspace characters and recode them to
' CHR$(29) (the LEFT cursor key):
DO
BackSpace = INSTR(InString$, CHR$(8))
IF BackSpace THEN
MID$(InString$, BackSpace) = CHR$(29)
END IF
LOOP WHILE BackSpace
' Look for line-feed characters and remove any found:
DO
LineFeed = INSTR(InString$, CHR$(10))
IF LineFeed THEN
InString$ = LEFT$(InString$, LineFeed - 1) + MID$(InString$, LineFeed + 1)
END IF
LOOP WHILE LineFeed
END SUB
DEFSNG A-Z
' Quick Basic Routine OpenCom
' This routine will accept the entire OPEN command parameters
' that is in QB 4.5 , the only exception is the baud rate and
' COM port. Baud rate is optional, if specified, this module
' will set the specifed rate up to 115,200. If the baud rate
' is specifed at 0, the specifed port will be polled for the
' current baud rate and the baud rate will be set at the rate
' that is present, if any. NOTE: the baud rate parameter on
' the command line IS NOT optional, if you want this module
' to set the baud rate, put an extra comma into the command
' line to replace the baud rate. The COM Port will accept up
' to COM 4 now.
'
' OPENCOM "COMX:{option list1 [baudrate,parity,databit]},{option list2}
' AS FileNum"
' examples:
' OPENCOM "COM1:38400 as 1"
' OPENCOM "COM4:,op500 as 1"
' OPENCOM "COM2:2400,n,8,1,op500 as 4"
' OPENCOM "COM3:,,, OP500 as 2"
' These routines were written by Michael Parker.
'
SUB OPENCOM (Sting$)
Sting$ = LTRIM$(RTRIM$(Sting$))
Port$ = UCASE$(LEFT$(Sting$, 5))
Sting$ = RIGHT$(Sting$, LEN(Sting$) - 5)
FOR x = 1 TO LEN(Sting$)
H$ = MID$(Sting$, x, 1)
IF UCASE$(H$) = "A" THEN
H$ = H$ + MID$(Sting$, x + 1, 1)
IF UCASE$(H$) = "AS" THEN
FileNum = VAL(MID$(Sting$, x + 2, LEN(Sting$)))
EXIT FOR
END IF
END IF
InputString$ = InputString$ + H$
NEXT x
FOR x = 1 TO LEN(InputString$)
IF MID$(InputString$, x, 1) <> "," THEN
BaudRate$ = BaudRate$ + MID$(InputString$, x, 1)
ELSE
InputString$ = MID$(InputString$, x + 1, LEN(InputString$))
EXIT FOR
END IF
NEXT x
IF LTRIM$(BaudRate$) = "" THEN
BaudRate& = 0
END IF
SELECT CASE Port$
CASE "COM1:"
BaseAddr% = &H3F8
Port1$ = "COM1:"
CASE "COM2:"
BaseAddr% = &H2F8
Port1$ = "COM2:"
CASE "COM3:"
BaseAddr% = &H2F8
Port1$ = "COM1:"
CASE "COM4:"
BaseAddr% = &H3F8
Port1$ = "COM2:"
CASE ELSE
PRINT "Illegal COM Port"
END SELECT
IF BaudRate$ = "" THEN
OUT BaseAddr% + 3, INP(BaseAddr% + 3) OR &H80
LSB% = INP(BaseAddr%)
MSB% = INP(BaseAddr% + 1)
OUT BaseAddr% + 3, INP(BaseAddr% + 3) AND &H7F
Divisor& = MSB% * &H100 + LSB%
IF Divisor& = 0 THEN
BaudRate& = 0
ELSE
BaudRate& = 115200 / Divisor&
END IF
ELSE
BaudRate& = VAL(BaudRate$)
END IF
IF LEFT$(InputString$, 1) <> "," THEN
InputString$ = "," + InputString$
END IF
OPEN Port1$ + "4800" + InputString$ FOR RANDOM AS FileNum
IF Port$ = "COM3:" THEN
POKE &H400, &HE8
ELSEIF Port$ = "COM4:" THEN
POKE &H402, &HE8
END IF
IF BaudRate& <> 0 THEN
Divisors# = 115200 / BaudRate&
END IF
LCR = BaseAddr% + 3
Temp = INP(LCR)
OUT LCR, Temp OR 128
OUT BaseAddr% + 1, INT(Divisors# / 256)
OUT BaseAddr%, Divisors#
OUT LCR, Temp AND 127
END SUB
'================end============================
Cheers! Ian
---------------------------------------------
Ian Musgrave Ph.D Prince Henry's Institue of Medical Research
PO Box 5152, Clayton 3168, Australia.
Phone +61 3 550 4286 FAX +61 3 550 6125