OK...

 BBS: SPOKANE CENTRAL
Date: 12-24-93 (08:43)             Number: 100
From: TWO BITZ #213 @5930          Refer#: 100
  To: PUBLIC POST                   Recvd: NO  
Subj: OK...                          Conf: (23) QUICKBASIC

Response To: FLAME #4 @5702 F> When I OPEN COM 1 in Quick Basic and I want to get some info from a user how F> do I do it. <...> F> it tells me I have a Buffer Overflow. How do I fix this? I like to use ON COM(x) GOSUB and ON ERROR GOTO Have you looked at Terminal.Bas in your QB example directory? Here's something I wrote a couple of years ago, it needs to be cleaned up for high-speed modems but I think it works fine at 2400. You can change the PRINT InStr$ to PRINT# and output the file to CONS: for ANSI color, but for some reason things seem to quit after a bit. I think QB trips up in it's I/O routines when using ON COM (x), but it's a good way to keep the modem buffer empty. Incoming modem data causes an IRQ and ON COM(x) will be called. Take a look at QBSERxxx.ZIP for another method. 'modem.bas is an ASCII terminal to demo an autodialer. DECLARE SUB Keyscan () DECLARE SUB Delay (td!) DECLARE SUB Dial (num$) ' Put all modem response into a 10k buffer declared global. COMMON SHARED ModemIn$ OPEN "COM2:2400,N,8,1" FOR RANDOM AS #1 ON ERROR GOTO Handler ON COM(2) GOSUB GetBuf COM(2) ON CALL Dial ("555-1212") DO CALL Keyscan ' You're online now. Stay in this loop forever. LOOP Handler: RESUME NEXT ' ignore all errors. GetBuf: InStr$ = INPUT$(LOC(1), #1) DO BackSpace = INSTR(InStr$, CHR$(8)) IF BackSpace THEN MID$(InStr$, BackSpace) = CHR$(29) END IF LOOP WHILE BackSpace DO LineFeed = INSTR(InStr$, CHR$(10)) IF LineFeed THEN InStr$ = LEFT$(InStr$, LineFeed - 1) + MID$(InStr$, LineFeed + 1) END IF LOOP WHILE LineFeed ModemIn$ = RIGHT$(ModemIn$ + InStr$, 10240) PRINT (InStr$); 'print modem buffer to screen. RETURN SUB Delay (td!) TimeDelay! = TIMER + td! WHILE TimeDelay! > TIMER: WEND END SUB SUB Dial (num$) CLS LOCATE 25, 40: PRINT "ALT-X to exit.." LOCATE 1, 1, 1 PRINT #1, "ATZ" CALL Delay(1) PRINT #1, "ATS7=45 S0=0 V1 M0" ' modem initialization string CALL Delay(1) DO CALL Delay(1) PRINT "Dialing ....." PRINT #1, "atdt" + Num$ + CHR$(13) TimeDelay! = TIMER + 40 DO UNTIL TIMER > TimeDelay! CALL Keyscan test = INSTR(RIGHT$(ModemIn$, 20), "CONNECT") IF test THEN result = -1: EXIT DO test = INSTR(RIGHT$(ModemIn$, 5), "BUSY") IF test THEN result = 0: EXIT DO test = INSTR(RIGHT$(ModemIn$, 12), "NO DIALTONE") IF test THEN result = 0: CALL Delay(2): EXIT DO test = INSTR(RIGHT$(ModemIn$, 11), "NO CARRIER") IF test THEN result = 0: CALL Delay(2): EXIT DO LOOP LOOP UNTIL result FOR t = 1 TO 5 ' It answered! ring the alarm! SOUND 750, 2 SOUND 550, 2 SOUND 650, 2 IF INKEY$ <> "" THEN EXIT FOR NEXT END SUB SUB Keyscan ' This would be a good place to check for PgDn/PgUp and shell to an ' external transfer protocol like Zmodem. a$ = INKEY$ IF a$ = CHR$(0) + CHR$(45) THEN CLOSE : END ' ALT-X to exit. PRINT #1, a$; ' send keypress to modem END SUB * SLMR 2.1a * $$49 WWIVMail/QWK 4.52 [REGISTERED]: SPOKANE CENTRAL - @5930 ON WWIVnet
Outer Court
Echo Basic Postings

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