home *** CD-ROM | disk | FTP | other *** search
- ' GrayLine.BAS For QuickBasic
- ' By Bob Dykeman 72371,3177 February 1994
- '
- ' This routine is the result of a need I found for reading long printed
- ' lines of text. The old "green bar" fanfold paper made this fairly
- ' easy to do, but I'm not aware of any green bar laser paper that
- ' is generally available. So, using the technical reference manual for my
- ' HP Laserjet III, I put together the following printer command sequences.
- ' The routine prints 11 gray bars (4% gray) across a portrait-oriented page
- ' in an HP Laserjet III series or later printer. (It may also work on
- ' the Laserjet II series and earlier, but I haven't been able to test it.
- ' If you find it works on those printers, I'd appreciate hearing about it.)
- '
- ' Because printer control codes can be somewhat difficult to follow, I've
- ' included abundant (perhaps TOO abundant) comments below. The entire
- ' routine can be reduced to 14-16 lines, including labels, if comments
- ' are removed.
- '
- ' After printing the gray bars, the printer's "cursor" returns to the top
- ' of the page, waits for normal text output from the program, and prints
- ' the text over the gray bars on the same page.
- '
- ' You can change the density of the gray in the appropriate line below,
- ' change the number of bars printed by the FOR/NEXT loop (in case you
- ' set the top and bottom page margins to something other than the default,
- ' since the printer cursor's "0,0" position is relative to the top and
- ' left margins, whether default or set), or change anything else you like.
-
- ' To change the gray density, change "CHR$(52)" (ASCII "4") to
- ' "2" = CHR$(50) for 2% gray, to "15" = CHR$(49);CHR$(53) for 15% gray, to
- ' "25" = CHR$(50);CHR$(53) for 25% gray, etc.
- '
- ' The routine will work for either portrait or landscape page orientation.
- ' Only two lines are different for the two orientations: the line setting
- ' the width of the bar, and the limit of the FOR/NEXT loop (7 or 10). I've
- ' included appropriately labelled commands for both (with the landscape
- ' line REM'd out). Remember to set your printer for the proper orientation
- ' before entering this routine:
- ' PORTRAIT: PRINT #1, CHR$(27);CHR$(38);CHR$(108);CHR$(48);CHR$(79);
- ' LANDSCAPE: PRINT #1, CHR$(27);CHR$(38);CHR$(108);CHR$(49);CHR$(79);
- '
- ' DO NOT DELETE the semicolons (;) at the end of each line - that is
- ' guaranteed to throw the whole bar and text line alignment way off because
- ' of the LF/CR QB puts at the end of each output line.
- '
- ' If you want to, you can move the first three printer code lines (that set
- ' the width and height of the bar, and the % gray) outside of this
- ' routine, since they actually only have to be run once.
- '
- ' Delete the appropriate line at the start and the appropriate line at the
- ' end of the routine, depending on whether you use it as a subroutine
- ' or a subprogram.
- '
- ' This routine assumes that the printer has already been opened for output
- ' as #1, and that it is set to the normal 60 lines per page.
- ' It's a good idea if you print the codes for "reset printer"
- ' [CHR$(27);CHR$(69);] somewhere right after opening the printer for
- ' output, and again after all of your printing is done, before closing
- ' #1.
- '
- ' To use the routine, call it at the start of each page of text, then
- ' print 60 lines of text (or less, of course) and issue a form feed
- ' [CHR$(12)]. Then call the routine again for the next page...etc.
- '
- ' I've benefited a lot from routines others have contributed to the general
- ' weal, and in the same vein, you are welcome to use this routine in any of
- ' your programs without compensation and to pass it on. Hope you find it useful.
- '
- '
- '****************** Start of routine ***********************
- '
- '=======================================
- '
- ' SUB GrayLinePortrait '* For SubProgram
- '
- ' GrayLinePortrait: '* For SubRoutine
- '
- '* PORTRAIT - Set width of rectangle (bar) = 2450 units *
- '* (printable width of LJ portrait page) *
- PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(50); CHR$(52); CHR$(53); CHR$(48); CHR$(65);
- '
- '* LANDSCAPE - Set width of rectangle (bar) = 3200 units *
- '* (printable width of LJ landscape page) *
- 'PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(51); CHR$(50); CHR$(48); CHR$(48); CHR$(65);
- '
- '* Set height of rectangle = 150 (3 rows of normal 1/6 inch/row) *
- PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(49); CHR$(53); CHR$(48); CHR$(66);
- '
- '* Set pattern ID to 4% gray *
- PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(52); CHR$(71);
- '* -------------------------------------
- '
- '* Set cursor position to 0,0 *
- PRINT #1, CHR$(27); CHR$(42); CHR$(112); CHR$(48); CHR$(120); CHR$(48); CHR$(89);
- '
- '* Print the rectangular shaded area (bar) *
- PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(50); CHR$(80);
- '
- FOR I = 1 TO 10 '* PORTRAIT - Print 10 more gray bars
- 'FOR I = 1 TO 7 '* LANDSCAPE - Print 7 more gray bars
- '
- '* Reset vertical cursor position down 6 lines (cursor returns to top *
- '* left of the bar after drawing it). This skip gives 3 gray lines *
- '* and 3 white lines. *
- PRINT #1, CHR$(27); CHR$(38); CHR$(97); CHR$(43); CHR$(54); CHR$(82);
- '
- '* Print the rectangular shaded area *
- PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(50); CHR$(80);
- '
- NEXT I
- '
- '* ------------------------------------
- '
- '* Reset cursor position to 0,0 *
- PRINT #1, CHR$(27); CHR$(42); CHR$(112); CHR$(48); CHR$(120); CHR$(48); CHR$(89);
- '
- '* Move the cursor down 36 points (relative) (1 line is 50) *
- '* to move it into the first gray bar (difference betwen 0,0 for the gray
- '* bars and 0,0 for text). *
- PRINT #1, CHR$(27); CHR$(42); CHR$(112); CHR$(43); CHR$(51); CHR$(54); CHR$(89);
- '
- '
- '* Reset the printer. If printing multiple pages, move this to the end
- '* of the printing routine, probably into the main module. *
- PRINT #1, CHR$(27); CHR$(69)
- '
- 'RETURN '* For SubRoutine *
- 'END SUB '* For SubProgram *
-
-