Microsoft KB Archive/35651
Article ID: 35651
Article Last Modified on 8/16/2005
- 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 Q35651
Most ASCII values display graphics or alphanumeric symbols when sent to the screen. However, there are some ASCII character codes for which Basic displays nothing on the screen of a PC. The list of excluded characters for the PRINT statement is the same as for the PRINT# statement sending output to a file opened with the "SCRN:" device name. The list of excluded characters is different for the "CONS:" and "SCRN:" device names, as shown below.
Note that you can display all the excluded character codes by directly poking them into video memory (under MS-DOS only, not in OS/2), as shown farther below.
This information applies to QuickBasic Versions 4.00, 4.00b, and 4.50 for MS-DOS and to the Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS.
For a table of the graphics and alphanumeric symbols associated with ASCII bytes, please refer to Appendix A of the Basic language reference manuals for QuickBasic Versions 4.00, 4.00b, and 4.50 for MS-DOS or the language reference manual for Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2. See also the QB Advisor online Help system for QuickBasic 4.50.
The following ASCII values cannot be output with PRINT, or with PRINT# to either "SCRN:" or "CONS:"
Decimal Hex ASCII Description ------- --- ----- ----------- 007 7H BEL Bell 009 9H HT Horizontal Tab 010 AH LF Linefeed 013 DH CR Carriage Return
PRINT# to "SCRN:" and PRINT output the following characters, but PRINT# to "CONS:" does not:
Decimal Hex ASCII Description ------- --- ----- ----------- 027 1BH ESC Escape 127 7FH (The DOS device CONS: recognizes code 127 as DEL.)
PRINT# to "CONS:" outputs the following control characters, but PRINT# to "SCRN:" and PRINT do not:
Decimal Hex ASCII Description ------- --- ----- ----------- 011 BH VT Vertical Tab 012 CH FF Formfeed 028 1CH FS 029 1DH GS 030 1EH RS 031 1FH US
There is a method in QuickBasic of displaying every character, including those on the above lists. This involves using the POKE statement to send the appropriate ASCII code into the even-numbered byte in video memory that corresponds to a particular screen position. (The color attribute (default=7) is POKEd into the odd byte that follows the even byte.) This requires knowing the starting address for the correct page of screen memory (as shown on Page 85 of the "Peter Norton Programmer's Guide to the IBM PC"), as well as the desired row and column position.
The following code POKEs a given ASCII character at a specific row and column position on a Hercules-compatible monochrome monitor:
DEF SEG = &HB000 'start of Hercules memory page 0. 'DEF SEG = &hB800 'start for EGA or CGA Cards page 0 DEFINT A-Z row = 10 column = 30 attribute = 7 'normal white-on-black Character = 7 'The bell, normally CharPos = 2 * (row * 80 + column) POKE CharPos, Character POKE CharPos + 1, attribute ' Additional characters can be POKEd here as desired. END
The following code verifies which characters can be displayed in QuickBasic. You can change "SCRN:" to "CONS:" and rerun for comparison. You can also change the < PRINT#1, > statement to the < PRINT > statement for comparison.
CLS OPEN "scrn:" FOR OUTPUT AS #1 FOR k = 0 TO 255 WHILE INKEY$ = "": WEND PRINT #1, k; CHR$(k) NEXT
Additional query words: QuickBas BasicCom