home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Magazin: Amiga-CD 1996 July
/
AMIGA_1996_7.BIN
/
patches
/
pagestream
/
3.0iupdate
/
macros.lha
/
PrintSignature.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-09-21
|
6KB
|
216 lines
/* $VER: PrintSignature.rexx 1.1 (13.9.95)
Copyright 1995 Soft-Logik Publishing Corporation
May not be distributed without Soft-Logik Publishing Corporation's express written permission */
OPTIONS RESULTS
ADDRESS 'PAGESTREAM'
/* MAIN LOOP */
call OPENLIBS()
iTemp = GETDOCINFO() /* get msys and page size */
if iTemp = 0 then do
iTemp = SIGREQ() /* get creep from user */
if iTemp = 0 then do
if dCreep > 0 then call CALCCREEP() /* calculate creep */
call OPENBUSY()
call CHANGESIZE() /* double the document width */
'refresh wait'
call MOVEONPAGE() /* move objects to correct page sides */
call MOVETOPAGE() /* move objects to correct spreads */
call CLOSEBUSY()
'refreshwindow'
'refresh continue'
end
end
EXIT
GETDOCINFO:
/* LET'S CHECK OUT THE DOCUMENT */
/* IS A DOCUMENT OPEN? */
sError = 'A document must be open to use this macro.'
signal on error
currentdocument
/* GET PAGE COUNT */
'getpagenumbering 'aPage
/* IS THE PAGE COUNT DIVISABLE BY 4? */
sError = 'The page count must be a multiple of four to use this macro.'
if trunc(aPage.length/4) ~= aPage.length/4 then signal error
/* GET PAGE SIZE */
'getpagemasterpage masterpage 'sMpage' page 1'
'getdimensions 'aMpage' masterpage "'sMpage'"'
sMsys = msys(aMpage.width)
dMpageX = p2d(aMpage.width,'pt')
dMpageY = p2d(aMpage.height,'pt')
/* GET DOCUMENT NAME. CREATE SIGNATURE NAME */
'currentdocument'
aDoc.name = result
aDoc.tname = aDoc.name
if length(aDoc.name) > 20 then aDoc.tname = left(aDoc.name,20)
aSig.name = aDoc.tname||'.signature'
/* CALCULATE THE SPREAD SIZE */
dSpageX = 2 * dMpageX
dSpageY = dMpageY
RETURN 0
SIGREQ:
/* PRINT SIGNATURE REQUESTER */
rcode=0
/* ALLOCATE REQUESTER */
allocarexxrequester '"Print Signature"' 338 71
hSigReq=result
/* ADD GADGETS */
addarexxgadget hSigReq EXIT 12 54 70 label "_Ok"
hOkGadget=result
addarexxgadget hSigReq EXIT 256 54 70 label "_Cancel"
hCancelGadget=result
addarexxgadget hSigReq TEXT 8 8 80 border none string "Signature"
sMpageX = p2d(dSpageX'pt',sMsys)
sMpageY = p2d(dSpageY'pt',sMsys)
addarexxgadget hSigReq TEXT 100 8 106 border recessed label "_Horz" string sMpageX||sMsys
addarexxgadget hSigReq TEXT 220 8 106 border recessed label "_Vert" string sMpageY||sMsys
addarexxgadget hSigReq STRING 44 28 162 label "'Paper C_reep'" string '0"'
hCreepGadget=result
/* SHOW REQUESTER */
doarexxrequester hSigReq
if result=hCancelGadget then rcode=9
else do
/* GET GADGET STATUS */
getarexxgadget hSigReq hCreepGadget string
dCreep=result
if dCreep=p2d(dCreep) then dCreep=dCreep||sMsys
dCreep=p2d(dCreep,'pt')
end
/* FREE REQUESTER */
freearexxrequester hSigReq
freearexxlist hSignatureList
RETURN rcode
CALCCREEP:
/* CALCULATE CREEP OFFSET */
dcreep=3/32
iStart = 1 /* define start/end values */
iEnd = aPage.length
iHalf= aPage.length / 2
aCreep.iStart = 0 /* zero creep for start and end */
aCreep.iEnd = 0
dCreep = dCreep / (aPage.length/4 - 1) /* calculate incremental creep value */
do i = iStart+1 to iEnd-1 /* repeat for all pages except first and last */
if i <= iHalf then aCreep.i = trunc((i-iStart)/2)*dCreep
if i > iHalf then aCreep.i = trunc((iEnd-i)/2)*dCreep
end i
do i = 1 to iEnd
aCreep.i = p2d(aCreep.i,'pt')
end i
RETURN
CHANGESIZE:
/* CREATE THE SIGNATURE */
'setdocumentname 'aSig.name' document 'aDoc.name
'setdimensions 'dSpageX'pt 'dSpageY'pt portrait single masterpage "'sMpage'"'
RETURN
MOVEONPAGE:
/* MOVE OBJECTS TO CORRECT PAGE SIDES AND SHIFT FOR CREEP */
do i = 1 to aPage.length by 2 /* repeat for each odd page */
if dCreep = 0 then aCreep.i = 0
'selectobject all page 'i
dOffset = dMpageX - aCreep.i
'move offset 'dOffset'pt '0'pt nosnap'
iBRcurrent = iBRcurrent + 1
call setbusy(iBRcurrent/iBRtotal*100)
end i
do i = 2 to aPage.length by 2 /* repeat for each even page */
if dCreep = 0 then aCreep.i = 0
'selectobject all page 'i
'move offset 'aCreep.i'pt '0'pt nosnap'
iBRcurrent = iBRcurrent + 1
call setbusy(iBRcurrent/iBRtotal*100)
end i
RETURN
MOVETOPAGE:
/* MOVE OBJECTS TO CORRECT SPREADS */
do i = aPage.length to (aPage.length/2)+1 by -1 /* repeat for all pages > page.count/2 */
'selectobject all page 'i
'movetopage page 'aPage.length-(i-1)
iBRcurrent = iBRcurrent + 1
call setbusy(iBRcurrent/iBRtotal*100)
end i
RETURN
OPENLIBS:
/* OPEN LIBRARIES */
IF ~SHOW('L','rexxsupport.library') THEN
call addlib('rexxsupport.library',0,-30)
IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN
call addlib("softlogik:libs/slarexxsupport.library", 0, -30)
RETURN
DOALERT:
parse arg sAlertText
iAlertLength=length(sAlertText)
/* Display an alert requester */
allocarexxrequester '"Macro Alert"' iAlertLength*8+24 55
hAlertReq=result
addarexxgadget hAlertReq TEXT 8 12 iAlertLength*8+8 border none string '"'sAlertText'"'
addarexxgadget hAlertReq EXIT iALertLength*8-58 38 70 label "_Exit"
doarexxrequester hAlertReq
freearexxrequester hAlertReq
RETURN
OPENBUSY:
openbusyrequester message "'Preparing Signature...'" thermometer enabled abort enabled total 100 current 0
hBusyReq=result
iBRcurrent = 0
iBRtotal = aPage.length * 1.5
RETURN
SETBUSY:
parse arg value
setbusyrequester hBusyReq current value
getbusyrequester hBusyReq
if result=1 then do
call closebusy()
exit
end
RETURN 0
CLOSEBUSY:
'closebusyrequester 'hBusyReq
RETURN
ERROR:
/* TRAP ERRORS */
call doalert(sError)
RETURN 9