Microsoft KB Archive/40632

From BetaArchive Wiki
Knowledge Base


If PRINT Fails on Non-Standard System, PRINT#n to "CONS: "

Article ID: 40632

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
  • Microsoft BASIC Professional Development System 7.0



This article was previously published under Q40632

SUMMARY

The PRINT and WRITE statements write directly to video memory; they do not write to the screen through function calls to MS-DOS or the ROM BIOS. This information applies to Microsoft QuickBasic Versions 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 Version 7.00 for MS-DOS and MS OS/2.

By circumventing MS-DOS and the ROM BIOS, the PRINT and WRITE statements may not work correctly with certain non-standard or unsupported operating-system configurations (such as PC-MOS, Multi-DOS, or multitasking packages added to MS-DOS).

To be more compatible with non-standard systems, you can send output to a logical device name that routes the characters through an MS-DOS character device driver.

For example, output through the "CONS:" (CONSole) or "CON" device name forces all output through the MS-DOS console device driver. The MS-DOS console device driver makes ROM BIOS calls to perform the output.

You can OPEN "CONS:" FOR OUTPUT AS #n and send output with the PRINT#n or WRITE#n statement.

Similarly, if you have trouble printing with LPRINT to a network printer, OPEN "LPT1:" FOR OUTPUT AS #n and send output with the PRINT#n or WRITE#n statement.

MORE INFORMATION

Some computer manufacturers provide an ANSI.SYS device driver on their DOS disk. Limited graphics control may be performed through ANSI control codes. For more information about ANSI codes, query on the following words:

PRINT# MS-DOS "CON" Device ANSI Escape Codes


The following device names supported by the OPEN statement are discussed on Pages 293 and 294 of the "Microsoft QuickBasic Version 4.0: Basic Language Reference" manual for Versions 4.00 and 4.00b:

"CONS:"
"KYBD:"
"SCRN:"
"COM1:", "COM2:"
"LPT1:", "LPT2:"


The following is a code example:

CLS
OPEN "CONS:" FOR OUTPUT AS #1
PRINT #1, "Howdy pahd-nuh..."
CLOSE #1
END
                


Additional query words: QuickBas BasicCom

Keywords: KB40632