Microsoft KB Archive/35667

From BetaArchive Wiki
Knowledge Base


OP Parameter Fails to Make OPEN "COM1: " Wait Indefinitely

Article ID: 35667

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b



This article was previously published under Q35667

SUMMARY

The manuals listed below incorrectly state that if the OP serial communications parameter is specified without a value, the OPEN COM statement will wait indefinitely for the port to be opened. The OPEN COM statement will actually wait only 10 seconds.

This correction applies to the following manuals on Pages 298 and 299:

  1. "Microsoft QuickBasic 4.0: Basic Language Reference" manual for Versions 4.00 and 4.00b
  2. "Microsoft Basic Compiler 6.0: Basic Language Reference" for Versions 6.00 and 6.00b for MS OS/2 and MS-DOS

This error also occurs on Page 255 of "Microsoft QuickBasic 4.5: Basic Language Reference" for Version 4.50.

This error has been corrected in the Microsoft Basic PDS Version 7.00 documentation.

Code Examples:

The following program demonstrates that you still get a time-out using the OP parameter:

DEFINT A-Z
PRINT "wait for open"
OPEN "com1:19200,n,8,,OP,rb4048" FOR RANDOM AS #1
PRINT "opened"
.
.
.
END
                

As a workaround, you can use the following program, which will wait indefinitely with the error handler returning to the OPEN COM line until it is opened:

ON ERROR GOTO check
trial = 0
OPEN "com1:9600,n,8,,OP,rb4048" FOR INPUT AS #1
PRINT "opened...."
END
check:
        IF ERR = 24 THEN
                trial = trial + 1
                PRINT "open attempt#"; trial
                RESUME
        ELSE
                PRINT "fatal error abort"
                END
        END IF
                


Additional query words: QuickBas BasicCom

Keywords: KB35667