home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / WordProcessors / slt-pgs3.lzx / PageStream3 / Scripts / PrintSignature.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-10-20  |  5.2 KB  |  209 lines

  1. /* $VER: PrintSignature.rexx 1.2 (09.10.96)
  2.    Copyright 1996 SoftLogik Publishing Corporation
  3.    May not be distributed without SoftLogik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. ADDRESS 'PAGESTREAM'
  7.  
  8.  
  9. /* MAIN LOOP */
  10. call OPENLIBS()
  11.  
  12.     iTemp = GETDOCINFO()                            /* get page size */
  13.  
  14.     if iTemp = 0 then do
  15.  
  16.         iTemp = SIGREQ()                            /* get creep from user */
  17.         if iTemp = 0 then do
  18.             if dCreep > 0 then call CALCCREEP()        /* calculate creep */
  19.             call OPENBUSY()
  20.             call CHANGESIZE()                        /* double the document width */
  21.             'refresh wait'
  22.             call MOVEONPAGE()                        /* move objects to correct page sides */
  23.             call MOVETOPAGE()                        /* move objects to correct spreads */
  24.             call CLOSEBUSY()
  25.             'refreshwindow'
  26.             'refresh continue'
  27.         end
  28.  
  29.     end
  30.  
  31. EXIT
  32.  
  33. GETDOCINFO:
  34. /* LET'S CHECK OUT THE DOCUMENT */
  35.  
  36.     /* IS A DOCUMENT OPEN? */
  37.     sError = 'A document must be open to use this macro.'
  38.     signal on error
  39.     currentdocument
  40.  
  41.     /* GET PAGE COUNT */
  42.     'getpagenumbering 'aPage
  43.  
  44.     /* IS THE PAGE COUNT DIVISABLE BY 4? */
  45.     sError = 'The page count must be a multiple of four to use this macro.'
  46.     if trunc(aPage.length/4) ~= aPage.length/4 then signal error
  47.  
  48.     /* GET PAGE SIZE */
  49.     'getpagemasterpage masterpage 'sMpage' page 1'
  50.     'getdimensions 'aMpage' masterpage "'sMpage'"'
  51.     dMpageX = aMpage.width
  52.     dMpageY = aMpage.height
  53.  
  54.     /* GET DOCUMENT NAME. CREATE SIGNATURE NAME */
  55.     'currentdocument'
  56.         aDoc.name = result
  57.         aDoc.tname = aDoc.name
  58.     if length(aDoc.name) > 20 then aDoc.tname = left(aDoc.name,20)
  59.         aSig.name = aDoc.tname||'.signature'
  60.  
  61.     /* CALCULATE THE SPREAD SIZE */
  62.     dSpageX = 2 * dMpageX
  63.     dSpageY = dMpageY
  64.  
  65. RETURN 0
  66.  
  67. SIGREQ:
  68. /* PRINT SIGNATURE REQUESTER */
  69. rcode=0
  70.  
  71.     /* ALLOCATE REQUESTER */
  72.     allocarexxrequester '"Print Signature"' 338 71
  73.         hSigReq=result
  74.  
  75.     /* ADD GADGETS */
  76.     addarexxgadget hSigReq EXIT 12 54 70 label "OK"
  77.         hOkGadget=result
  78.     addarexxgadget hSigReq EXIT 256 54 70 label "Cancel"
  79.         hCancelGadget=result
  80.     addarexxgadget hSigReq TEXT 8 8 80 border none string "Signature"
  81.     sMpageX = dSpageX
  82.     sMpageY = dSpageY
  83.     addarexxgadget hSigReq TEXT 136 8 70 border recessed label "_Horz" string sMpageX
  84.     addarexxgadget hSigReq TEXT 256 8 70 border recessed label "V_ert" string sMpageY
  85.     addarexxgadget hSigReq STRING 136 26 70 label "'Paper C_reep'" string '0'
  86.         hCreepGadget=result
  87.  
  88.     /* SHOW REQUESTER */
  89.     doarexxrequester hSigReq
  90.     if result=hCancelGadget then rcode=9
  91.     else do
  92.         /* GET GADGET STATUS */
  93.         getarexxgadget hSigReq hCreepGadget string
  94.             dCreep=result
  95.     end
  96.  
  97.     /* FREE REQUESTER */
  98.     freearexxrequester hSigReq
  99.     freearexxlist hSignatureList
  100.  
  101. RETURN rcode
  102.  
  103. CALCCREEP:
  104. /* CALCULATE CREEP OFFSET */
  105.  
  106. dcreep=3/32
  107.     iStart = 1                                                    /* define start/end values */
  108.     iEnd = aPage.length
  109.     iHalf= aPage.length / 2
  110.  
  111.     aCreep.iStart = 0                                            /* zero creep for start and end */
  112.     aCreep.iEnd = 0
  113.  
  114.     dCreep = dCreep / (aPage.length/4 - 1)                        /* calculate incremental creep value */
  115.  
  116.     do i = iStart+1 to iEnd-1                                    /* repeat for all pages except first and last */
  117.         if i <= iHalf then aCreep.i = trunc((i-iStart)/2)*dCreep
  118.         if i > iHalf then aCreep.i = trunc((iEnd-i)/2)*dCreep
  119.     end i
  120.  
  121. RETURN
  122.  
  123. CHANGESIZE:
  124. /* CREATE THE SIGNATURE */
  125.     'setdocumentname 'aSig.name' document 'aDoc.name
  126.     'setdimensions 'dSpageX' 'dSpageY' portrait single masterpage "'sMpage'"'
  127. RETURN
  128.  
  129. MOVEONPAGE:
  130. /* MOVE OBJECTS TO CORRECT PAGE SIDES AND SHIFT FOR CREEP */
  131.  
  132.     do i = 1 to aPage.length by 2                    /* repeat for each odd page */
  133.         if dCreep = 0 then aCreep.i = 0
  134.         'selectobject all page 'i
  135.         dOffset = dMpageX - aCreep.i
  136.         'move offset 'dOffset' '0' nosnap'
  137.         iBRcurrent = iBRcurrent + 1
  138.         call setbusy(iBRcurrent/iBRtotal*100)
  139.     end i
  140.  
  141.     do i = 2 to aPage.length by 2                    /* repeat for each even page */
  142.         if dCreep = 0 then aCreep.i = 0
  143.         'selectobject all page 'i
  144.         'move offset 'aCreep.i' '0' nosnap'
  145.         iBRcurrent = iBRcurrent + 1
  146.         call setbusy(iBRcurrent/iBRtotal*100)
  147.     end i
  148.  
  149. RETURN
  150.  
  151. MOVETOPAGE:
  152. /* MOVE OBJECTS TO CORRECT SPREADS */
  153.  
  154.     do i = aPage.length to (aPage.length/2)+1 by -1        /* repeat for all pages > page.count/2 */
  155.         'selectobject all page 'i
  156.         'movetopage page 'aPage.length-(i-1)
  157.         iBRcurrent = iBRcurrent + 1
  158.         call setbusy(iBRcurrent/iBRtotal*100)
  159.     end i
  160.  
  161. RETURN
  162.  
  163. OPENLIBS:
  164.     /* OPEN LIBRARIES */
  165.     IF ~SHOW('L','rexxsupport.library') THEN
  166.         call addlib('rexxsupport.library',0,-30)
  167.     IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN
  168.         call addlib("softlogik:libs/slarexxsupport.library", 0, -30)
  169. RETURN
  170.  
  171. DOALERT:
  172. parse arg sAlertText
  173. iAlertLength=length(sAlertText)
  174. /* Display an alert requester */
  175.     allocarexxrequester '"Macro Alert"' iAlertLength*8+24 55
  176.         hAlertReq=result
  177.     addarexxgadget hAlertReq TEXT 8 12 iAlertLength*8+8 border none string '"'sAlertText'"'
  178.     addarexxgadget hAlertReq EXIT iALertLength*8-58 38 70 label "Exit"
  179.     doarexxrequester hAlertReq
  180.     freearexxrequester hAlertReq
  181. RETURN
  182.  
  183. OPENBUSY:
  184.     openbusyrequester message "'Preparing Signature...'" thermometer enabled abort enabled total 100 current 0
  185.         hBusyReq=result
  186.     iBRcurrent = 0
  187.     iBRtotal = aPage.length * 1.5
  188. RETURN
  189.  
  190. SETBUSY:
  191.     parse arg value
  192.     setbusyrequester hBusyReq current value
  193.     getbusyrequester hBusyReq
  194.     if result=1 then do
  195.         call closebusy()
  196.         exit
  197.     end
  198. RETURN 0
  199.  
  200. CLOSEBUSY:
  201.     'closebusyrequester 'hBusyReq
  202. RETURN
  203.  
  204. ERROR:
  205. /* TRAP ERRORS */
  206.     call doalert(sError)
  207.  
  208. RETURN 9
  209.