Q(uick)BASIC Statement: SCREEN
Quick View
SCREEN
A graphics statement that sets the specifications for the display screen
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- SCREEN mode% [,[colorswitch%] [,[activepage%] [,visualpage%]]]
Description/Parameter(s)
mode% | Sets the screen mode. See ⮜ Screen Modes ⮞. | ||||||||||||||
colorswitch% | A value (0 or 1) that switches between color and monocolor display (modes 0 and 1 only): | ||||||||||||||
|
|||||||||||||||
activepage% | The screen page that text or graphics output writes to. | ||||||||||||||
visualpage% | The screen page that is currently displayed on your screen. |
Example
'This example requires a color graphics adapter.
SCREEN 1 '320 x 200 graphics
LINE (110, 70)-(190, 120), , B
LINE (0, 0)-(320, 200), 3, , &HFF00
Syntax
- SCREEN [mode][,[colorswitch]][,[apage]][,[vpage]]
Description/Parameter(s)
Argument | Description |
mode | An integer constant or expression indicating the screen mode. See ⮜ Screen Mode Summary ⮞ for a list of the valid mode numbers. |
colorswitch | Determines whether color is displayed on composite monitors. The colorswitch is a numeric expression in the range 0-255.
|
apage | A numeric expression that is the number of the screen page that text output or graphics commands write to. See ⮜ Adapters and Displays ⮞ for the number of pages available for each graphics adapter. |
vpage | A numeric expression that is the number of the screen page being displayed. |
Example
See any of the following example programs, which use the SCREEN statement:
the ⮜ CIRCLE statement programming example ⮞,
the ⮜ DRAW statement programming example ⮞, or
the ⮜ LINE statement programming example ⮞.
Syntax
- SCREEN mode% [, [colorswitch%] [, [activepage%] [,visiblepage%]] ]
Description/Parameter(s)
mode% | An integer constant or expression that selects a screen mode for a particular combination of display and adapter. |
See ⮜ Screen Mode Summary ⮞ for a list of the valid mode numbers. | |
colorswitch% | An integer expression that switches composite monitor display between color and noncolor (modes 0 and 1 only). |
activepage% | An integer expression that identifies the screen page that text or graphics output is written to. |
visiblepage% | An integer expression that identifies the screen page that is displayed. |
In OS/2 protected mode, BASIC supports only screen modes 0-2 and does not support the activepage% and visiblepage% arguments. In OS/2 real mode, BASIC supports screen modes 0-4 and 7-13. |
Optimization Note
- If mode% is an expression, rather than a constant, and if you know your program will not use certain screen modes, you can achieve a smaller .EXE file by linking with one or more stub files:
If not using screen modes: Link to file: 1 or 2 NOCGA.OBJ 3 NOHERC.OBJ 4 NOOGA.OBJ 7, 8, 9, or 10 NOEGA.OBJ 11, 12, or 13 NOVGA.OBJ - If you do not need graphics in your custom run-time module (because the programs use screen mode 0 only), you can save 15K by creating the run-time module with NOGRAPH.OBJ.
Syntax Notes
- See for a list of the valid mode% numbers.
- The argument colorswitch% is effective only for screen modes 0 and 1 and for composite monitors:
Screen mode 0 Screen mode 1 To disable color, use... 0 A non-zero value To enable color, use... A non-zero value 0 - See ⮜ Adapters and Displays ⮞ for the valid ranges for apage% and vpage% for each graphics adapter.
- See ⮜ Attributes and Colors ⮞ for a list of the default color attributes for different screen modes.
Example
This example uses the SCREEN statement to set up a multipage EGA or VGA mode 7 (320x200) display. A help screen is displayed for several seconds, then copied (using the PCOPY statement) to page 2 for later use. A cube is displayed and rotated on the screen. By pressing Shift+F1, the user can again see the help screen, after which the cube display is resumed.
DEFINT A-Z
'Define a macro string to draw a cube and paint its sides.
One$ = "BR30 BU25 C1 R54 U45 L54 D45 BE20 P1, 1G20 C2 G20"
Two$ = "R54 E20 L54 BD5 P2, 2 U5 C4 G20 U45 E20 D45 BL5 P4, 4"
Plot$ = One$ + Two$
'Initialize values for active page, visual page, help page, and angle
'of rotation.
APage% = 0
VPage% = 1
HPage% = 2
Angle% = 0
'Create a HELP screen on the visual page.
SCREEN 7, 0, VPage%, VPage%
LOCATE 1, 18
PRINT "HELP"
LOCATE 5, 1
PRINT "Press 'Alt+F1' keys to see this HELP"
PRINT "screen while the cube is rotating"
PRINT "around the center of the screen. "
PRINT
PRINT "After a brief delay, the cube will"
PRINT "resume at the next point in it's"
PRINT "rotation."
PRINT
PRINT "Press any other key to exit the"
PRINT "program. "
'Put a copy of the help screen in page 2.
PCOPY VPage%, HPage%
SLEEP 5
DO
SCREEN 7, 0, APage%, VPage%
'Clear the active page.
CLS 1
'Rotate the cube Angle% degrees.
DRAW "TA" + STR$(Angle%) + Plot$
'Angle% is some multiple of 15 degrees.
Angle% = (Angle% + 15) MOD 360
'Drawing is complete. Make the cube visible in its new position
'by swapping the active and visual pages.
SWAP APage%, VPage%
'Check the keyboard input.
Kbd$ = INKEY$
SELECT CASE Kbd$
'If Shift+F1 is pressed, show the HELP page.
CASE CHR$(0) + CHR$(104)
PCOPY HPage%, APage%
SLEEP 3
'Do nothing if no key is pressed.
CASE ""
CASE ELSE
EXIT DO
END SELECT
LOOP
END