Q(uick)BASIC Statement: VIEW PRINT

Quick View

VIEW PRINT

A device I/O statement that sets the boundaries of the screen text viewport

Worth knowing

Useful and cross-version information about the programming environments of QBasic and QuickBasic.

Syntax
  • VIEW PRINT [toprow% TO bottomrow%]
Description/Parameter(s)
toprow% The number of the top row of the text viewport.
bottomrow% The number of the bottom row of the text viewport.
If you omit the toprow% and bottomrow% arguments, VIEW PRINT sets the entire screen as the text viewport.
Ranges for toprow% and bottomrow% depend on the screen mode.
Example
VIEW PRINT 10 TO 15 FOR i% = 1 TO 100 'Output will scroll. PRINT i% NEXT i%
Syntax
  • VIEW PRINT [topline TO bottomline]
Description/Parameter(s)

The topline argument is the number of the upper line in the viewport; the bottomline is the number of the lower line.

Without topline and bottomline parameters, the VIEW PRINT statement initializes the whole screen area as the text viewport. The number of lines in the screen depends on the screen mode and whether or not the /H option was used when QuickBASIC was started. For more information, see the WIDTH statement details .

Statements and functions that operate within the defined text viewport include CLS, LOCATE, PRINT, and the SCREEN function.

Example

See the CLS statement programming example , which uses the VIEW PRINT statement.

Syntax
  • VIEW PRINT [topline% TO bottomline%]
Description/Parameter(s)
topline% An integer expression; the top of the text viewport.
bottomline% An integer expression; the bottom of the new text viewport.
  • Use no arguments to set the text viewport boundaries to entire screen.
  • Ranges for topline% and bottomline% values depend on the screen mode.
  • Statements that operate within the text viewport include CLS, LOCATE, PRINT, WRITE, INPUT, and the SCREEN function.

Usage Notes

  • Without the arguments topline% and bottomline%, the VIEW PRINT statement initializes the whole screen area as the text viewport. The number of text lines in the screen depends on the screen mode and whether or not the /H option was used when BASIC was started. For more information, see the WIDTH statement details.
Example

This example uses the VIEW PRINT statement to set up graphics and text viewports. The CLS statement is used to clear the graphics viewport after 30 circles have been drawn and the text viewport after "Hello" has been printed 45 times.

RANDOMIZE TIMER SCREEN 1 'Set up a graphics viewport with a border. VIEW (5, 5)-(100, 80), 3, 1 'Set up a text viewport. VIEW PRINT 12 TO 24 'Print a message on the screen outside the text viewport. LOCATE 25, 1: PRINT "Press any key to stop." Count = 0 DO 'Draw a circle with a random radius. CIRCLE (50, 40), INT((35 - 4) * RND + 5), (Count MOD 4) 'Clear the graphics viewport every 30 times. IF (Count MOD 30) = 0 THEN CLS 1 PRINT "Hello. "; 'Clear the text viewport every 45 times. IF (Count MOD 45) = 0 THEN CLS 2 Count = Count + 1 LOOP UNTIL INKEY$ <> ""