Knowledge Base |

# "Bad File Name"; OPEN "COM1: "; 8 Data Bits Must Have No Parity

Article ID: 12027

Article Last Modified on 11/21/2006

This article was previously published under Q12027

## SUMMARY

When you use the OPEN "COM" statement with the data bits set to 8 and parity set to Even or Odd, you will get a "Bad File Name" error. For example, "Bad File Name" occurs at run time when you open the serial communications port as follows:

       OPEN "COM1:9600,E,8,1" AS 2

This error disappears using 7 data bits, or No (N) parity.
When you specify 8 data bits, you must specify a parity of N. This is a limitation in the design of QuickBasic versions 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50; Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2; and Microsoft Basic PDS versions 7.00 and 7.10 for MS-DOS and MS OS/2.

## MORE INFORMATION

As a workaround in QuickBasic versions 4.00 and later, Microsoft Basic Compiler versions 6.00 or 6.00b, or Basic PDS, you can call a Microsoft C version 5.10 routine from Basic to do the communications with 8 bits and odd or even parity. The following book will help in doing this:

"Microsoft C Programming for the IBM" by Robert Lafore (published by the Waite Group)

The QuickBasic Compiler, Basic compiler 6.00, and Basic PDS 7.00 are designed with a 10-bit data frame for communications. The frame is as follows:

                1 2  -  8 9 A
                S DDDDDDD P S

    Bit  1     = Start Bit    (Always 1)
    Bits 2 - 8 = Data Bits    (7 or 8)
    Bit  9     = Parity       (Odd, Even, or None)
    Bit  A     = Stop Bit(s)  (1 or 2)

The combination of the bits should add up to 10 bits. When you try to set 1 start + 8 data + 1 parity + 1 stop, that adds up to an 11-bit data frame, which Basic is not designed for.

Additional query words: QuickBas BasicCom

Keywords: KB12027