Microsoft KB Archive/40897

= If Communications Buffer Overflows During Output to &quot;COM1: &quot; =

Article ID: 40897

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft BASIC Interpreter 3.0 for Macintosh
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q40897



SUMMARY
If the communications buffer overflows, overprints, or fails when outputting to the &quot;COM1:&quot; device, such as to a plotter, Apple ImageWriter printer, or other hardware, it is probably due to the fact that the Macintosh hardware handshaking has not been turned on.

The machine language program below invokes the _CONTROL ROM call to turn on the hardware handshaking for &quot;COM1:&quot;. This program can be used with the following products:


 * 1) Microsoft QuickBASIC Version 1.00 for the Apple Macintosh
 * 2) Microsoft BASIC Compiler Version 1.00 for the Apple Macintosh
 * 3) Microsoft BASIC Interpreter Version 3.00 for the Apple Macintosh

This program is not necessary for earlier (1.x, 2.x) versions of the Microsoft BASIC Interpreter for Macintosh, where hardware handshaking is ON by default.



MORE INFORMATION
To support the Apple Personal Modem, QuickBASIC Version 1.00 and the BASIC interpreter Version 3.00 set &quot;COM1:&quot; hardware handshaking OFF. Unfortunately, this can cause buffer overrun problems to occur with devices that rely on hardware handshaking.

Please note that Macintosh QuickBASIC and earlier versions of Macintosh BASIC support only one communications port, &quot;COM1:&quot;, which is marked with a phone icon on the back of the Macintosh. QuickBASIC does not offer a feature to change the communications parameters for the &quot;LPT1:&quot; printer port, which is marked with a printer icon on the back of the Macintosh.

Code Example
The following code example turns ON hardware handshaking to prevent buffer overflow problems on hardware that requires handshaking ON: OPEN &quot;COM1:9600,n,8,1&quot; AS #1 ' Substitute your OPEN &quot;COM1:...&quot; here. DIM Code%(100) n=0 : hdhs=0 FOR j=0 TO 15  ' This loop READs machine language code into an array. READ n Code%(j)=n NEXT hdhs=VARPTR(Code%(0))   ' Get address of array. CALL hdhs ' Call the machine language instructions (stored in array) ' It is now possible to output with PRINT#n to the &quot;COM1:&quot; device. END ' Below are machine language instructions (represented as ' hexadecimal constants) that invoke the _CONTROL ROM routine. DATA &H41FA,&H001E DATA &H317C,&HFFF9,&H18 DATA &H317C,&H000A,&H001A DATA &H217C,&H001,&H1113,&H1C DATA &H42A8,&H0020 DATA &HA004 DATA &H4E75

Additional query words: BasicCom MQuickB

Keywords: KB40897

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.