home *** CD-ROM | disk | FTP | other *** search
- \ Display a file formatted into pages with titles
- \
- \ (PAGINATE ( -- ) \ Paginate the file whose descriptor is in ifd
- \ "PAGINATE ( filename -- ) \ Paginate the named file
- \ PAGINATE \ filename ( -- ) \ Paginate the named file
- \ LINES/PAGE ( -- adr ) \ Variable; # of lines per page
- \ LEFT-MARGIN ( -- adr ) \ Variable; # of spaces to indent
- \ BOTTOM-MARGIN ( -- adr ) \ Variable; # of lines to leave at the bottom
- \
- \ The output normally goes to the screen. To send it to the printer, use:
- \ PRINT PAGINATE filename
- \ PRINT is defined in PRINTER.FTH
-
- decimal
- only forth also definitions
- needs fgetline extend/filetool.fth
- only forth also definitions decimal
-
- variable lines/page 66 lines/page !
- variable left-margin 4 left-margin !
- variable bottom-margin 4 bottom-margin !
- variable page#
- variable end-reached
-
- h# 104 buffer: paginate-filename
-
- : .heading ( -- )
- cr cr
- .today space .now
- 42 to-column paginate-filename ".
- 70 to-column ." Page " page# @ .d cr
- cr cr ;
- : .footing ( -- )
- lines/page @ #line @ ?do cr loop ;
- : 1page ( -- )
- #line off .heading
- lines/page @ bottom-margin @ - #line @
- ?do
- pad ifd @ fgetline ( [ str ] flag )
- if ". cr else end-reached on leave then
- loop
- .footing 1 page# +! ;
- : (paginate ( -- ) \ Formats an already-open file
- end-reached off 1 page# !
- begin 1page end-reached @ until
- paginate-filename off ifd @ fclose ;
- : "paginate ( filename -- )
- dup paginate-filename "copy
- read-open (paginate ;
- : paginate \ filename ( -- )
- blword "paginate ;
-