\ Load Screen for PRINT Utility 5 /15/88ONLY FORTH ALSO DEFINITIONS 1 6 +THRU CR .( Print Utility Loaded ) ONLY FORTH ALSO DEFINITIONS \S The Print Utility allows you to print a range of screens on your printer. If your printer allows it, you can print 6 screens per page. The top level word is SHOW which takes a starting and ending screen number and prints all the non blank screens within the range. SHOW in the EDITOR prints the screens and their shadows. The print utility is initialized by INIT-PR, which defaults to EPSON. If you don't have an EPSON MX-80 set INIT-PR to an appropriately defined word for your printer. If your printer cannot print 132 columns per line, then you should use TRIAD instead. \ Variables and Setup 5 /15/88: EPSON ( -- ) CONTROL O EMIT ( EPSON Condensed ) ; DEFER INIT-PR ' NOOP IS INIT-PR DEFER FOOTING 66 CONSTANT L/PAGE 0 CONSTANT LOGO VARIABLE #PAGE : PAGE ( -- ) DOES> PERFORM 1 #PAGE +! #LINE OFF #OUT OFF ; PAGE : FORM-FEED ( -- ) CONTROL M EMIT CONTROL L EMIT ; : (PAGE) ( -- ) L/PAGE #LINE @ OVER MIN ?DO CR LOOP ; ' (PAGE) IS PAGE HIDDEN DEFINITIONS CREATE SCR#S 14 ALLOT ( enough room for 6 Screens ) \ Print 2 screens across on a page 5 /15/88: TEXT? ( Scr# -- f ) BLOCK DUP C@ BL ASCII ~ BETWEEN ( printable ) IF B/BUF -TRAILING NIP 0<> ( and not empty ) ELSE FALSE THEN ; : PR ( scr -- ) DUP CAPACITY >= IF DROP LOGO THEN 1 SCR#S +! SCR#S DUP @ 2* + ! ; : 2PR ( Scr1# Scr2# line# -- ) CR DUP 2 .R SPACE C/L * >R PAD 129 BLANK SWAP BLOCK R@ + PAD C/L CMOVE BLOCK R> + PAD C/L + 1+ C/L CMOVE PAD 129 -TRAILING TYPE ; : 2SCR ( Scr1 Scr2 --- ) CR CR 4 SPACES OVER 4 .R 61 SPACES DUP 4 .R 16 0 DO 2DUP I 2PR LOOP 2DROP ; \ Prints 6 screen on a page 5 /15/88: P-HEADING ( -- ) CR CR 5 SPACES ." Page# " #PAGE ? 8 SPACES 8 SPACES .PATH ." \" FILE? CR ; : P-FOOTING ( -- ) CR CR 58 SPACES ." Forth 83 Model" PAGE ; ' P-FOOTING IS FOOTING \ Prints 6 screen on a page 6 /10/88: PR-START ( -- ) 10 10 20 1 $600 $600 OW SINGLE ." PRINTING" PRINTING ON #LINE OFF ['] PR-TYPE IS TYPE SCR#S OFF 1 #PAGE ! INIT-PR ; : PR-STOP ( -- ) PRINTING OFF CLOSE ; : PR-PAGE ( -- ) P-HEADING SCR#S OFF SCR#S 2+ 3 0 DO DUP @ OVER 6 + @ 2SCR 2+ LOOP DROP FOOTING ; : PR-S-PAGE ( -- ) P-HEADING SCR#S OFF SCR#S 2+ 3 0 DO DUP @ OVER 2+ @ 2SCR 4 + LOOP DROP FOOTING ; : PR-FLUSH ( -- f ) SCR#S @ DUP ( Any screens left over? ) IF BEGIN SCR#S @ 5 < WHILE 0 PR REPEAT LOGO PR THEN 0<> ; \ Shadow Screen Support 5 /15/88ONLY FORTH ALSO DEFINITIONS VOCABULARY SHADOW ALSO SHADOW DEFINITIONS : DISPLACEMENT ( fcb -- disp ) [ DOS ] fsize B/BUF UM/MOD NIP 2/ ; : (>SHADOW) ( scr# fcb -- scr#' ) DISPLACEMENT 2DUP < IF + ELSE - THEN ; : >SHADOW ( scr# -- scr#' ) FILE @ (>SHADOW) ; : >IN-SHADOW ( scr# -- scr#' ) IN-FILE @ (>SHADOW) ; \ Print Page with Shadows 5 /15/88FORTH DEFINITIONS : SHOW ( first last -- ) [ HIDDEN ] PR-START 1+ SWAP ?DO I TEXT? IF I PR THEN SCR#S @ 6 = IF PR-PAGE THEN LOOP PR-FLUSH IF PR-PAGE THEN PR-STOP ; SHADOW DEFINITIONS : SHOW ( first last -- ) [ HIDDEN ALSO ] PR-START 1+ SWAP ?DO I TEXT? IF I PR I [ SHADOW ] >SHADOW PR THEN SCR#S @ 6 = IF PR-S-PAGE THEN LOOP PR-FLUSH IF PR-S-PAGE THEN PR-STOP ; ONLY FORTH ALSO DEFINITIONS : LISTING ( -- ) 0 CAPACITY 2/ 1- [ SHADOW ] SHOW ; \ Variables and Setup 5 /15/88EPSON sets EPSON MX-80 printer to 132 column mode. INIT-PR sets printer to 132 column. Default is EPSON. FOOTING Print a message at the bottom of the page. LOGO The Screen number of your LOGO screen L/PAGE The number of lines per page. PAGE# The current page number as we are printing. PAGE Printer dependent. Get to a new page. Increment the page number and reset the line number and the column number. FORM-FEED Print a form feed character. (PAGE) Print enough linefeeds to get to next page. The following words are used only in this utility: SCR#S An array to hold a count and 6 screen numbers. \ Print 2 screens across on a page 5 /15/88TEXT? ( Scr# -- f ) Given a screen number, returns true if the first character in the screen is printable and the screen is not blank. PR ( scr -- ) Add the screen to the array and increment the pointers. If it is out of range, replace it with the logo screen. 2PR ( Scr1# Scr2# line# -- ) Print the specified line from the two screens given on the stack. The line from scr2 is copied to pad and the line from scr1 is appended, and the result is printed. 2SCR ( Scr1 Scr2 --- ) Print 2 screens across on a page. Calls 2PR on a line by line basis. \ Prints 6 screen on a page 5 /15/88P-HEADING ( -- ) Prints the heading for each new page. P-FOOTING ( -- ) Prints the footing for each new page. Assumes form feed works \ Prints 6 screen on a page 5 /15/88PR-START Initialize everything. PR-STOP Resets the deferred word TYPE to send to terminal. PR-PAGE ( -- ) Prints a page worth of screens without shadows. The screens are printed in vertical columns, 6 up on a page. PR-S-PAGE ( -- ) Prints a page worth of screens with shadows. The source code appears in the left column, and the associated shadow on the right column. PR-FLUSH ( -- f ) Fills the SCR#S array if a page is partially filled. Returns true if there is more to print, otherwise false. \ Print Page with Shadows 5 /15/88SHOW is the used to print a range of screens, from first to last. Screens are printed six to each page. This requires a printer capable of 132 columns per line. Some printers, like the Epson, must be put into a mode where 132 columns per line are available. Blank screens are not printed. SHADOW SHOW is similar, but prints three screens and their three shadows on each page. Typical usage: 1 20 SHOW or 1 20 SHADOW SHOW See the multi-tasker for an example of print spooling. LISTING print entire file, with shadows.