BBS: Inland Empire Archive Date: 03-21-92 (11:07) Number: 188 From: KEVIN NEWELL Refer#: NONE To: MIKE CLARK Recvd: NO Subj: QB Routines Conf: (2) Quik_Bas
Hello Mike! Here is some routines that I have in use in my programs. These all should work, but I can only guarentee that they work on COM2. I really just pulled out the code from my programs, so I hope you can follow my code... BTW, the only variable that I use for user input is the comport. You can substitute some other variables to make it more user configurable though... NOTE: The Comport number in these routines are actually Comport -1 ...
-- AnsiCheck ' checks for Remote ANSI use... SendOut$ = CHR$(27) + "[6n" ' Send string out com port PRINT #2, SendOut$; SLEEP 2 'MUST DO THIS to allow return time IF NOT EOF(2) THEN RetStr$ = INPUT$(LOC(2), 2) ' Import answer... IF INSTR(RetStr$, CHR$(27)) THEN 'then ansi is set Red1$ = CHR$(27) + "[1;31m" Green1$ = CHR$(27) + "[1;32m" Gellow1$ = CHR$(27) + "[1;33m" Blue1$ = CHR$(27) + "[1;34m" Blink$ = CHR$(27) + "[5m" ELSE 'no remote ansi Red1$ = "" yellow1$ = "" Green1$ = "" Blue1$ = "" Blink$ = "" END IF
-- CheckCom 'Gets the current Baud Rate from Specifed Port IF port$ = "0" THEN BaseAddr% = &H3F8 Port1$ = "COM1:" ELSEIF port$ = "1" THEN BaseAddr% = &H2F8 Port1$ = "COM2:" ELSEIF port$ = "2" THEN BaseAddr% = &H2F8 Port1$ = "COM1:" ELSEIF port$ = "3" THEN BaseAddr% = &H3F8 Port1$ = "COM2:" ELSE CLS PRINT "Invalid Port!" END IF 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
-- Set BaudRate 'Sets BaudRate to Specified Rate for Specified Rate 'NOTE: I use the output from previous routine for input here. OPEN Port1$ + "300,N,8,1,op500,cd500,tb32767,lf" FOR RANDOM AS #2 IF port$ = "2" THEN POKE &H400, &HE8 ELSEIF port$ = "3" THEN POKE &H402, &HE8 END IF AllReadyHere$ = "YES" 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
-- CloseCom 'Close the specified COM port without DROPPING Carrier CLOSE SELECT CASE port$ CASE "0" OUT &H3FC, 3 CASE "1" OUT &H2FC, 3 CASE "2" OUT &H3EC, 3 CASE "3" OUT &H2EC, 3 END SELECT -- GoldED 2.31p --- GoldED 2.31p * Origin: --> Treasure Island {309} 346-2074 @14.4 *HST/V42b* (1:232/200)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET