home *** CD-ROM | disk | FTP | other *** search
- EXTERNAL
-
- SUB Page (line$(),arg$)
- !
- ! Page
- !
- ! a True BASIC(tm), Inc. product
- !
- ! ABSTRACT
- ! Sends a True BASIC program to the [first]
- ! printer port and prints the file with page
- ! headers; inserts a form feed at page breaks.
- !
- ! SYNTAX
- ! DO PAGE
- ! DO PAGE,String for page header
- !
- ! Copyright (c) 1988 by True BASIC, Inc.
- !
- CALL initialise ! default characteristics
- CALL open_channel ! find file to use & get it
- !
- ! Print each line of the current file. If a
- ! line is longer than the page width, print it
- ! in parts.
- !
- FOR i = 1 to Ubound(line$) ! loop through current file
- LET qaz$ = line$(i) ! get next line
- DO ! loop in case line too long
- CALL processor(qaz$[1:page_width]) ! print what fits
- LET qaz$[1:page_width] = "" ! done with this part
- LOOP until Len(qaz$) = 0 ! loop till all parts printed
- NEXT i
- STOP ! done...
- !
- SUB initialise
- IF arg$ <> "" then
- LET formatted_name$ = arg$ ! name specified on DO command
- ELSE
- LET formatted_name$ = "True BASIC(tm)" ! supply default
- END IF
-
- LET page_width = 60 ! width of printing area
- LET margin = 3 ! top & bottom margins (2 minimum)
- LET pagelength = 66 ! lines on page
-
- LET linenum = Maxnum ! force inital header
- LET ff$ = Chr$(Ord("FF")) ! a form feed
- !
- ! Create a string with date and time for use in header
- !
- LET datetime$ = Date$[5:6] & "/" & Date$[7:8] & "/" & Date$[3:4]
- LET datetime$ = Time$[1:5] & " - " & datetime$ & " "
- END SUB
-
- SUB open_channel
- DO
- WHEN exception in ! protect in case of error
- OPEN #99: printer ! get out of loop if ok
- SET #99: margin page_width
- EXIT DO
- USE
- PRINT "Sorry, "; extext$ ! explain the error
- STOP
- END WHEN
- LOOP
- END SUB
-
- SUB processor(data_string$)
- LET linenum = linenum + 1
- IF linenum >= pagelength-margin then ! end of page?
- PRINT #99: ff$; ! form feed to start new page
- LET pages = pages + 1 ! increment page count
- CALL header ! print the header
- END IF
- PRINT #99: data_string$ ! print the line
-
- IF Pos(data_string$,ff$) <> 0 then ! if the line had a form feed
- LET pages = pages + 1 ! then...
- CALL header ! print a header
- END IF
- END SUB
-
- SUB header
- !
- ! Print a header after a form feed - skip one line,
- ! print header info, then skip any more lines needed to
- ! fill out the top margin.
- !
- PRINT #99:
- LET x$ = datetime$ & "Page " & Str$(pages)
- LET xtab = page_width - Len(x$) ! right justify
- PRINT #99: formatted_name$; Tab(xtab); x$
- !
- ! Fill out top margin
- !
- FOR j = 1 to margin-2
- PRINT #99:
- NEXT j
- LET linenum = margin ! current line
- END SUB
-
- END SUB
-