home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / propage4.0 / arexx / cmdprint.pprx < prev    next >
Encoding:
Text File  |  1995-08-30  |  5.7 KB  |  184 lines

  1. /* This genie uses the CMD command to speed up printing of multiple copies to a non-Postscript printer. A second program, CMDcopy, must be present in your Rexx: directory.
  2. */
  3.  
  4. /* $VER: CMDprint Aug 95 */
  5.  
  6. /*call open("STDERR","ram:traceCMD","W")
  7. trace r*/
  8.  
  9. oldunits = ppm_GetUnits()
  10. call ppm_SetUnits(2) /* work in metric throughout */
  11. call ppm_AutoUpdate(0)
  12.  
  13. call SafeEndEdit.rexx()
  14. cr="0a"x
  15.  
  16. Autotile = d2y(ppm_GetDMAutotile())
  17. ColorCorrect = d2y(ppm_GetDMColorCorrect())
  18. Dither = ppm_GetDMDither()
  19. select
  20.     when dither = 0 then dither = "O"
  21.     when dither = 1 then dither = "H"
  22.     when dither = 2 then dither = "F"
  23.     otherwise dither = "invalid"
  24.     end
  25. Density = ppm_GetDMDensity()
  26. Eject = d2y(ppm_GetDMEject())
  27. Landscape = ppm_GetDMLandscape()
  28. select
  29.     when landscape = 0 then landscape = "P"
  30.     when landscape = 1 then landscape = "L"
  31.     otherwise landscape = "invalid"
  32.     end
  33. Offset = ppm_GetDMOffset()
  34. OffsetX = word(Offset,1)*10 /* convert to mm */
  35. OffsetY = word(Offset,2)*10
  36. PageSize = ppm_GetDMPageSize()
  37. PageWidth = word(PageSize,1)*10
  38. PageHeight = word(Pagesize,2)*10
  39. PrintMode = ppm_GetDMPrintMode()
  40. select
  41.     when PrintMode = 0 then PrintMode = "B"
  42.     when printmode = 1 then PrintMode = "G"
  43.     when PrintMode = 2 then PrintMode = "C"
  44.     otherwise PrintMode = "invalid"
  45.     end
  46. Proof = ppm_GetDMProof()
  47. select
  48.     when Proof = 0 then Proof = "D"
  49.     when Proof = 1 then Proof = "F"
  50.     otherwise Proof = "invalid"
  51.     end
  52. Scale = ppm_GetDMScale()
  53. ScaleX = word(Scale,1)
  54. ScaleY = word(Scale,2)
  55. copies = getclip("CMDcopies")
  56. if copies = "" then copies = 2
  57. if ~datatype(copies, n) then copies = 2
  58.  
  59.  
  60.  
  61. formstring = "Number of copies:"copies || cr||"Autotile (Y/N):"Autotile ||cr|| "Color Correct(Y/N):"ColorCorrect ||cr|| "Dither (O/H/F):"Dither ||cr|| "Density (1-7):"Density ||cr|| "Eject (Y/N):"Eject ||cr|| "Landscape (L/P):"Landscape ||cr|| "Offset X (mm):"OffsetX ||cr|| "Offset Y (mm):"OffsetY ||cr|| "Pagewidth (mm):"Pagewidth ||cr|| "Page height (mm):"Pageheight ||cr|| "Print mode (B/G/C):"Printmode ||cr|| "Proof (D/F):"Proof ||cr|| "Scale X:"ScaleX ||cr|| "Scale Y:"ScaleY
  62. form = ppm_GetForm("Print Specs",14,formstring)
  63.  
  64. parse var form copies '0a'x autotile '0a'x colorcorrect '0a'x dither '0a'x density '0a'x eject '0a'x landscape '0a'x OffsetX '0a'x OffsetY '0a'x Pagewidth '0a'x Pageheight '0a'x Printmode '0a'x proof '0a'x ScaleX '0a'x ScaleY
  65.  
  66. if ~datatype(copies,n) then copies = 2
  67. call setclip('CMDcopies',copies) /* for collection by copy program */
  68. autotile = y2d(autotile)
  69. if autotile ~= "invalid" then call ppm_SetDMAutotile(autotile)
  70. colorcorrect = y2d(colorcorrect)
  71. if colorcorrect ~= "invalid" then call ppm_SetDMColorCorrect(colorcorrect)
  72.  
  73. dither = upper(left(strip(dither),1))
  74. select
  75.     when dither = "O" then dither = 0
  76.     when dither = "H" then dither = 1
  77.     when dither = "F" then dither = 2
  78.     otherwise dither = ppm_GetDMdither()
  79.     end
  80. call ppm_SetDMdither(dither)
  81.  
  82. if ~datatype(density,n) then density = 4
  83. density = trunc(density)
  84. density = max(density,1)
  85. density = min(density,7)
  86. call ppm_SetDMDensity(density)
  87.  
  88. eject = y2d(eject)
  89. if eject ~= "invalid" then call ppm_SetDMeject(eject)
  90. landscape = upper(left(strip(landscape),1))
  91. select
  92.     when landscape = "P" then call ppm_SetDMLandscape(0)
  93.     when landscape = "L" then call ppm_SetDMLandscape(1)
  94.     otherwise NOP
  95.     end
  96. if datatype(OffsetX,n) then OffsetX = OffsetX/10 /* convert to cm */
  97. else OffsetX = word(ppm_GetDMOffset(),1)
  98. if datatype(OffsetY,n) then OffsetY = OffsetY/10 /* convert to cm */
  99. else OffsetY = word(ppm_GetDMOffset(),2)
  100. if datatype(Pagewidth,n) then Pagewidth = Pagewidth/10 
  101. else Pagewidth = word(ppm_GetDMPagesize(),1)
  102. if datatype(Pageheight,n) then Pageheight = Pageheight/10 
  103. else Pageheight = word(ppm_GetDMPagesize(),2)
  104. if abs(OffsetX)>Pagewidth then OffsetX = word(ppm_GetDMOffset(),1)
  105. if abs(OffsetY)>Pageheight then OffsetY = word(ppm_GetDMOffset(),2)
  106. call ppm_SetDMOffset(OffsetX,OffsetY)
  107. call ppm_SetDMPageSize(Pagewidth,pageheight)
  108.  
  109. printmode = upper(left(strip(printmode),1))
  110. select
  111.     when printmode = "B" then printmode = 0
  112.     when printmode = "G" then printmode = 1
  113.     when printmode = "C" then printmode = 2
  114.     otherwise printmode = ppm_GetDMprintmode()
  115.     end
  116. call ppm_SetDMprintmode(printmode)
  117.  
  118. proof = upper(left(strip(proof),1))
  119. select
  120.     when proof = "D" then call ppm_SetDMproof(0)
  121.     when proof = "F" then call ppm_SetDMproof(1)
  122.     otherwise NOP
  123.     end
  124.  
  125. if ~datatype(ScaleX,n) then ScaleX = word(ppm_GetDMScale(),1)
  126. if ~datatype(ScaleY,n) then ScaleY = word(ppm_GetDMScale(),2)
  127. call ppm_SetDMSCale(ScaleX,ScaleY)
  128.  
  129. call open('infile',"ENV:Sys/printer.prefs","R")
  130. prefbytes = readch('infile',30000)
  131. call close('infile')
  132. serpar = substr(prefbytes,50,1)
  133. if serpar = 1 then pport = "serial"
  134. else pport = "parallel"
  135. pport2 = left(pport,3)||":"
  136. call setclip("CMDpport2",pport2)
  137.  
  138.  
  139. tempfile = ppm_GetFileName("Set file for temporary storage","RAM:",)
  140. if tempfile = "" then exit_msg("Aborted by user")
  141. call setclip('CMDtempfile',tempfile)
  142.  
  143. address command
  144. 'run >nil: cmd 'pport '"'tempfile'"'
  145. call ppm_PrintDocDM(1,1)
  146.  
  147. /*'run >nil: rx CMDcopy.rexx'*/
  148.  
  149. call exit_msg("Done")
  150. exit
  151.  
  152.  
  153. exit_msg:
  154.     do
  155.     parse arg message
  156.     if message ~= "" then call ppm_Inform(1,message,"Resume")
  157.     call ppm_ClearStatus()
  158.     call ppm_PPageToFront()
  159.     call ppm_AutoUpdate(1)
  160.     call ppm_SetUnits(oldunits)
  161.     exit
  162.     end
  163.  
  164.  
  165. d2y: procedure /* converts 0 or 1 to N or Y */
  166. parse arg numeral
  167. select
  168.     when numeral = 1 then output = "Y"
  169.     when numeral = 0 then output = "N"
  170.     otherwise output = "invalid"
  171.     end
  172. return output
  173.  
  174. y2d: procedure
  175. parse arg letter
  176. letter = left(strip(letter),1)
  177. select
  178.     when upper(letter) = "Y" then output = 1
  179.     when upper(letter) = "N" then output = 0
  180.     otherwise output = "invalid"
  181.     end
  182. return output
  183.  
  184.