Microsoft KB Archive/50461

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


COLOR Statement in SCREEN 11 Gives "Illegal Function Call"

Article ID: 50461

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS



This article was previously published under Q50461

SUMMARY

The COLOR statement correctly returns an "Illegal Function Call" if used in SCREEN 11. The only way to change the color in SCREEN 11 is to use the PALETTE statement. However, note that the PALETTE statement may not work with a video card that is not 100-percent compatible with the IBM standard VGA or MCGA. (SCREEN 11 requires VGA or MCGA.)

The following resources incorrectly state that the COLOR statement is valid in SCREEN modes 11-13; they should instead say SCREEN modes 12-13:

  1. Two occurrences, on Page 109 of the "Microsoft QuickBasic 4.0: Basic Language Reference" manual for QuickBasic Versions 4.00 and 4.00b
  2. Two occurrences, on Page 109 of the "Microsoft Basic Compiler 6.0: Basic Language Reference" manual for Versions 6.00 and 6.00b
  3. One occurrence, under the COLOR statement in the QB Advisor online Help system for QuickBasic Version 4.50


MORE INFORMATION

This documentation error was corrected in the "Microsoft QuickBasic 4.5: Basic Language Reference" manual for QuickBasic Version 4.50, in the Microsoft Basic Professional Development System (PDS) 7.00 "Basic Language Reference," and in the Microsoft Advisor online Help system in the QuickBasic Extended editor (QBX.EXE) shipped with Basic PDS Version 7.00.

The PALETTE statement can be used instead of the COLOR statement in SCREEN 11 to set the foreground and background colors. Note that the foreground color can only be set for graphics statements; text will always be blue.

To change the foreground color in SCREEN 11, the following PALETTE statement must be used:

   PALETTE 1, color
                

To change the background color in SCREEN 11, the following PALETTE statement must be used:

   PALETTE 0, color
                

Below is another code example demonstrating how to set the foreground and background colors in SCREEN 11 using the PALETTE statement:

' VGA color equation: COLOR number = 65536 * blue + 256 * green + red
'   where red, blue, and green are numbers between 0 and 63
CLS
SCREEN 11
background& = 256 * 63   'bright green
foreground& = 63         'bright red
PALETTE 0, background& 
PALETTE 1, foreground& 
LINE (10, 240)-(630, 240)
WHILE INKEY$ = "": WEND


Additional query words: QuickBas BasicCom

Keywords: KB50461