Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DAY 039: VIEW PRINT
#1
Every SCREEN ZERO HERO needs this keyword...

SYNTAX VIEW PRINT [topRow% TO bottomRow%]

Usage: Restricts the printable area of the screen.

Okay, let's take this puppy for a spin.

Use VIEW PRINT anytime you want to divide your text screen into a skin and message area.

Code: (Select All)
msg$ = "My Header"
COLOR 15, 1
LOCATE 1, 1: PRINT SPACE$(_WIDTH * 2);
LOCATE _HEIGHT - 1, 1: PRINT SPACE$(_WIDTH * 2);
LOCATE _HEIGHT, 1: PRINT SPACE$(_WIDTH);
LOCATE 1, _WIDTH / 2 - LEN(msg$) / 2: PRINT msg$;
LOCATE 2, 1: PRINT STRING$(_WIDTH, 196);
LOCATE _HEIGHT - 1, 1: PRINT STRING$(_WIDTH, 196);
PALETTE 5, 25
COLOR 7, 5
top% = 3
bottom% = _HEIGHT - 2
VIEW PRINT top% TO bottom%
CLS 2
msg$ = "Press [1] for info  /  Press [2] to make fun of Steve  /  Press [Esc] to end"
COLOR 15, 1: LOCATE _HEIGHT, _WIDTH / 2 - LEN(msg$) / 2: PRINT msg$; ' Look, we can print to the last row without changing VIEW PRINT.
LOCATE top%, 1
COLOR 7, 5
DO
    _LIMIT 30
    b$ = INKEY$
    IF LEN(b$) THEN
        SELECT CASE b$
            CASE "1"
                PRINT "INFO!"
            CASE "2"
                PRINT "Ha Ha Ha! ";
            CASE CHR$(27)
                EXIT DO
        END SELECT
    END IF
LOOP
SYSTEM

What's cool about VIEW PRINT is it leaves the last row unrestricted. That means we can print to the last row anytime we want, without changing the VIEW PRINT parameters.

What else do we need to know here, Pete?

Well, glad you asked!

1) CLEAR does not affect VIEW PRINT.

2) RUN removes VIEW PRINT.

3) CLS clears the whole screen.

4) CLS 2 only clears the VIEW PRINT area.

5) To get rid of the view print restriction, just code: VIEW PRINT

6) Remember when printing to the bottom of the screen to end your print statement with a semi-colon, so it doesn't scroll.

7) If you switch screens and switch back, you will have to redo your VIEW PRINT statement.

8) The top parameter must always be smaller than the bottom parameter. (If you're too dumb to figure that one out, switch to FreeBASIC).


Pete
Reply


Messages In This Thread
DAY 039: VIEW PRINT - by Pete - 12-19-2022, 04:48 AM
RE: DAY 039: VIEW PRINT - by mnrvovrfc - 12-19-2022, 10:34 AM
RE: DAY 039: VIEW PRINT - by SMcNeill - 12-19-2022, 11:52 AM
RE: DAY 039: VIEW PRINT - by bplus - 12-19-2022, 11:10 AM
RE: DAY 039: VIEW PRINT - by Dav - 12-19-2022, 01:49 PM



Users browsing this thread: 1 Guest(s)