Article ID: 42854
Article Last Modified on 1/9/2003
APPLIES TO
- Microsoft QuickBasic Compiler for Macintosh 1.0
This article was previously published under Q42854
SUMMARY
OPENing COM1: to output to a printer may cause random characters to be printed or overprinted. This is related to the amount of time required for communications port handshaking. To correct the problem, you must turn on hardware handshaking as shown in a separate article in this KnowledgeBase -- query for IMAGEWRITER AND COM1 AND _CONTROL.
This information relates to Macintosh QuickBASIC Version 1.00 and Macintosh BASIC Interpreter Version 3.00. Earlier versions have hardware handshaking on by default, and the buffer overflow does not occur.
MORE INFORMATION
The following program causes an ImageWriter II printer to print out random characters at the end of the output.
OPEN "COM1:9600" FOR OUTPUT AS #1 FOR i = 1 TO 100 PRINT #1, "Now its time for all good men..." NEXT i CLOSE #1
Aside from turning on hardware handshaking with machine language, you may also work around the problem by inserting a delay loop in between each PRINT #n statement to provide enough time for the handshaking process between QuickBASIC and the printing device to occur. For example, you could modify the previous example to look like the following:
OPEN "COM1:9600" FOR OUTPUT AS #1 FOR i = 1 TO 100 PRINT #1, "Now its time for all good men..." FOR j = 1 TO 500:NEXT j 'Delay loop NEXT i CLOSE #1
Note: The timing of a FOR NEXT loop is machine dependent; therefore, the number of iterations in the delay may have to be increased or decreased from one machine to the next.
Additional query words: MQuickB
Keywords: KB42854