home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / screen / grline / grayline.bas
Encoding:
BASIC Source File  |  1994-02-17  |  6.0 KB  |  130 lines

  1. ' GrayLine.BAS                          For QuickBasic
  2. ' By Bob Dykeman 72371,3177             February 1994
  3. '
  4. ' This routine is the result of a need I found for reading long printed
  5. ' lines of text. The old "green bar" fanfold paper made this fairly
  6. ' easy to do, but I'm not aware of any green bar laser paper that
  7. ' is generally available. So, using the technical reference manual for my
  8. ' HP Laserjet III, I put together the following printer command sequences.
  9. ' The routine prints 11 gray bars (4% gray) across a portrait-oriented page
  10. ' in an HP Laserjet III series or later printer. (It may also work on
  11. ' the Laserjet II series and earlier, but I haven't been able to test it.
  12. ' If you find it works on those printers, I'd appreciate hearing about it.)
  13. '
  14. ' Because printer control codes can be somewhat difficult to follow, I've
  15. ' included abundant (perhaps TOO abundant) comments below. The entire
  16. ' routine can be reduced to 14-16 lines, including labels, if comments
  17. ' are removed.
  18. '
  19. ' After printing the gray bars, the printer's "cursor" returns to the top
  20. ' of the page, waits for normal text output from the program, and prints
  21. ' the text over the gray bars on the same page.
  22. '
  23. ' You can change the density of the gray in the appropriate line below,
  24. ' change the number of bars printed by the FOR/NEXT loop (in case you
  25. ' set the top and bottom page margins to something other than the default,
  26. ' since the printer cursor's "0,0" position is relative to the top and
  27. ' left margins, whether default or set), or change anything else you like.
  28.  
  29. ' To change the gray density, change "CHR$(52)" (ASCII "4") to
  30. ' "2" = CHR$(50) for 2% gray, to "15" = CHR$(49);CHR$(53) for 15% gray, to
  31. ' "25" = CHR$(50);CHR$(53) for 25% gray, etc.
  32. '
  33. ' The routine will work for either portrait or landscape page orientation.
  34. ' Only two lines are different for the two orientations: the line setting
  35. ' the width of the bar, and the limit of the FOR/NEXT loop (7 or 10). I've
  36. ' included appropriately labelled commands for both (with the landscape
  37. ' line REM'd out). Remember to set your printer for the proper orientation
  38. ' before entering this routine:
  39. ' PORTRAIT: PRINT #1, CHR$(27);CHR$(38);CHR$(108);CHR$(48);CHR$(79);
  40. ' LANDSCAPE: PRINT #1, CHR$(27);CHR$(38);CHR$(108);CHR$(49);CHR$(79);
  41. '
  42. ' DO NOT DELETE the semicolons (;) at the end of each line - that is
  43. ' guaranteed to throw the whole bar and text line alignment way off because
  44. ' of the LF/CR QB puts at the end of each output line.
  45. '
  46. ' If you want to, you can move the first three printer code lines (that set
  47. ' the width and height of the bar, and the % gray) outside of this
  48. ' routine, since they actually only have to be run once.
  49. '
  50. ' Delete the appropriate line at the start and the appropriate line at the
  51. ' end of the routine, depending on whether you use it as a subroutine
  52. ' or a subprogram.
  53. '
  54. ' This routine assumes that the printer has already been opened for output
  55. ' as #1, and that it is set to the normal 60 lines per page.
  56. ' It's a good idea if you print the codes for "reset printer"
  57. ' [CHR$(27);CHR$(69);] somewhere right after opening the printer for
  58. ' output, and again after all of your printing is done, before closing
  59. ' #1.
  60. '
  61. ' To use the routine, call it at the start of each page of text, then
  62. ' print 60 lines of text (or less, of course) and issue a form feed
  63. ' [CHR$(12)]. Then call the routine again for the next page...etc.
  64. '
  65. ' I've benefited a lot from routines others have contributed to the general
  66. ' weal, and in the same vein, you are welcome to use this routine in any of
  67. ' your programs without compensation and to pass it on. Hope you find it useful.
  68. '
  69. '
  70. '****************** Start of routine ***********************
  71. '
  72. '=======================================
  73. '
  74. ' SUB GrayLinePortrait                  '* For SubProgram
  75. '
  76. ' GrayLinePortrait:                     '* For SubRoutine
  77. '
  78. '* PORTRAIT - Set width of rectangle (bar) = 2450 units *
  79. '* (printable width of LJ portrait page) *
  80. PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(50); CHR$(52); CHR$(53); CHR$(48); CHR$(65);
  81. '
  82. '* LANDSCAPE - Set width of rectangle (bar) = 3200 units *
  83. '* (printable width of LJ landscape page) *
  84. 'PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(51); CHR$(50); CHR$(48); CHR$(48); CHR$(65);
  85. '
  86. '* Set height of rectangle = 150 (3 rows of normal 1/6 inch/row) *
  87. PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(49); CHR$(53); CHR$(48); CHR$(66);
  88. '
  89. '* Set pattern ID to 4% gray *
  90. PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(52); CHR$(71);
  91. '* -------------------------------------
  92. '
  93. '* Set cursor position to 0,0 *
  94. PRINT #1, CHR$(27); CHR$(42); CHR$(112); CHR$(48); CHR$(120); CHR$(48); CHR$(89);
  95. '
  96. '* Print the rectangular shaded area (bar) *
  97. PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(50); CHR$(80);
  98. '
  99. FOR I = 1 TO 10           '* PORTRAIT - Print 10 more gray bars
  100. 'FOR I = 1 TO 7            '* LANDSCAPE - Print 7 more gray bars
  101. '
  102.         '* Reset vertical cursor position down 6 lines (cursor returns to top *
  103.         '* left of the bar after drawing it). This skip gives 3 gray lines *
  104.         '* and 3 white lines. *
  105.         PRINT #1, CHR$(27); CHR$(38); CHR$(97); CHR$(43); CHR$(54); CHR$(82);
  106. '
  107.         '* Print the rectangular shaded area *
  108.         PRINT #1, CHR$(27); CHR$(42); CHR$(99); CHR$(50); CHR$(80);
  109. '
  110. NEXT I
  111. '
  112. '*  ------------------------------------
  113. '
  114. '* Reset cursor position to 0,0 *
  115. PRINT #1, CHR$(27); CHR$(42); CHR$(112); CHR$(48); CHR$(120); CHR$(48); CHR$(89);
  116. '
  117. '* Move the cursor down 36 points (relative) (1 line is 50) *
  118. '* to move it into the first gray bar (difference betwen 0,0 for the gray
  119. '* bars and 0,0 for text). *
  120. PRINT #1, CHR$(27); CHR$(42); CHR$(112); CHR$(43); CHR$(51); CHR$(54); CHR$(89);
  121. '
  122. '
  123. '* Reset the printer. If printing multiple pages, move this to the end
  124. '* of the printing routine, probably into the main module. *
  125. PRINT #1, CHR$(27); CHR$(69)
  126. '
  127. 'RETURN                                 '* For SubRoutine *
  128. 'END SUB                                '* For SubProgram *
  129.  
  130.