home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / infxdl86.lzh / INFPRINT.CMD < prev    next >
OS/2 REXX Batch file  |  1994-01-24  |  5KB  |  174 lines

  1. /**/ 
  2. /* infprint.cmd 
  3. Some HPL5 control codes----picked up from 2up.cmd.
  4.  X2C(1B45)                  /* esc E         - reset printer*/
  5.  x2c(1B266C2641)          /* esc&l&A       - select A4 paper*/
  6.  x2c(B266C314F)        /*   esc&l1O       - select orientation*/
  7.  x2c(1B266C3145)       /*    esc&l1E       - set top margin*/
  8.  x2c(1B28733054)       /*    esc(s0T       - typeface for primary*/
  9.  x2c(1B28313055)         /*  esc(10U       - select character set*/
  10.  x2c(1B287331362E3648)  /* esc(s16.6H    - select font pitch for primary*/
  11.  x2c(1B266C3844)        /*  esc&l8D       - set line pitch*/*/
  12.  
  13.  
  14.  call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'Sysloadfuncs'
  15.  call Sysloadfuncs
  16.  
  17. arg mypar  setpar
  18. call inihandler 
  19. if mypar = s  then do 
  20. call setup
  21. exit
  22. end /*do */
  23. else nop
  24. if setpar = s  then call setup
  25. back = 0
  26. ricoh = 'lpt1:'
  27. if portrait = 1  then lperp = portlperp
  28. else lperp = landlperp
  29. if portrait = 1 then prtll = 120
  30. else prtll = 85
  31. if portrait = 1 then cd=X2C(1B451B266C26411B266C304F1B266C31451B283130551B287331362E36481B266C3844)
  32.                 else cd=X2C(1B451B266C26411B266C314F1B266C31451B283130551B287331362E36481B266C3844)
  33. prnfile = mypar
  34. yfile = stream(prnfile,c,query exists)
  35. if yfile = "" then exit
  36. tempfile = 'cwtcwt.cwt'
  37. tmpric = stream(tempfile,c,query exists)
  38. if tmpric \= "" then call sysfiledelete tempfile
  39. tmpric = stream(tempfile,c,open)
  40. if portrait = 1 then fullside = lperp
  41. else fullside = (lperp/2)
  42. page = 0
  43. n = 0
  44. do until lines(prnfile) < 1
  45. do  n = 1 to lperp
  46. stub.n = linein(prnfile)
  47. end
  48. call printlines
  49. drop stub.
  50. end  /* Do */
  51. if oneside = 0  then call backprint
  52. exit
  53. /*-------------------------------------------------*/
  54. BACKPRINT:
  55.  
  56. say 'Printing even numbered pages.'
  57. say 'Wait for printing to finish then turn the paper over'
  58. say 'and press any key to print odd numbered pages on reverse'
  59. pull ent
  60. ricoh = 'lpt1:'
  61. do forever      
  62. thisline = ""
  63. thisline = linein(tempfile)
  64. call lineout ricoh, thisline
  65. if lines(tempfile)<1 then leave
  66. end /* do */
  67. call lineout tempfile
  68. call sysfiledelete cwtcwt.cwt
  69. return
  70. /*----------------------------------------------------*/
  71. PRINTLINES:
  72. r = 0
  73. page = page + 1
  74. back = ¬back
  75. if oneside = 1  then back = 0
  76. if back = 1 then do 
  77. ricoh = tempfile
  78. spmgin = 5
  79. end  /* Do */
  80. else do 
  81. ricoh = 'lpt1:'
  82. spmgin = 2
  83. if oneside = 1 then spmgin = 5
  84. end /* do */
  85. filepage = prnfile||'  Page '||page
  86. topline = copies(' ',(160-(portrait*80)-length(filepage)))||filepage
  87. underline = copies(' ',(160-(portrait*80)-length(filepage)))||copies('═',length(filepage))
  88. call charout ricoh, cd
  89. call lineout ricoh,topline
  90. call lineout ricoh,underline
  91. do t = 1 to fullside
  92. sd = t + fullside
  93. if sd > n  then stub.sd = " "
  94. if t > n then stub.t = " "
  95. if portrait = 1 then alline.t = copies(' ',spmgin)||'║   '||left(stub.t, prtll)
  96. else alline.t = copies(' ',spmgin)||'║   '||left(stub.t, prtll)||'║   '||left(stub.sd, prtll)||'║'
  97. call lineout ricoh, alline.t  
  98. end
  99. call lineout ricoh
  100. return
  101. /*----------------------------------------------------------*/
  102. setup:
  103. do forever
  104. cls
  105. if portrait = 1 then orient = 'portrait'
  106. else orient = 'landscape'
  107. if oneside = 1  then sideno = 'one side'
  108. else sideno = 'both sides'
  109. call syscurpos 4,0
  110. say '           Orientation set to 'orient
  111. say '           Print on 'sideno' of paper'
  112. say '           Lines per page is 'portlperp' portrait'
  113. say '           Lines per page is 'landlperp' landscape'
  114. say   ''
  115. say '          Select'
  116. say '            O - to change orientation'
  117. say '            P - for one/both sides printing'
  118. say '            L - to alter lines per page'
  119. say '            S - to save current settings as default'
  120. say '            Q - to return to program'
  121. pull nsel
  122. select
  123. when nsel = o then portrait = ¬portrait
  124. when nsel = p then oneside = ¬oneside
  125. when nsel = l  then call lset
  126. when nsel = q  then return
  127. when nsel = s  then do
  128. call sysfiledelete inifile
  129. newiniline = portrait' 'portlperp' 'landlperp' 'oneside
  130. call lineout inifile, newiniline
  131. call lineout inifile
  132. end /*do */
  133. otherwise nop
  134. end /*select*/
  135. end /* do */
  136. return
  137.  
  138. /*------------------------------------------------------*/
  139. INIHANDLER:
  140. inifile = 'infprnt.ini'
  141.  yini = stream(inifile,c,query exists)
  142.  if yini = ""  then do
  143.           iniline = "0 85 118 1"
  144.           call lineout inifile,iniline
  145.           end
  146. else nop
  147. iniset = linein(inifile,1,1)
  148. parse value iniset with portrait portlperp landlperp oneside
  149. call lineout inifile
  150. return
  151. /*----------------------------------------------------------*/
  152. lset:
  153. say '   Alter Portrait or Landscape'
  154. pull pol
  155. if pol = p | pol = l then do
  156. say 'New lines per page'
  157. pull llpp
  158. if datatype(llpp) = num & llpp > 0  then do
  159. if pol = p  then portlperp = llpp
  160. else landlperp = llpp
  161. end /*do */
  162. else nop
  163. end /*do*/
  164. else nop
  165. return
  166. /*----------------------------------------------------------*/
  167. Original release - infprint.cmd b0.15 21st June 1993.
  168. See infextra.doc for details.
  169. Modify and use as you please at your risk.
  170.  written by Colin Thomson.
  171. Fidonet at STRANGE***daze***(2:250/313)
  172. /*----------------------------------------------------------*/
  173.  
  174.