home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Magazin: Amiga-CD 1996 July
/
AMIGA_1996_7.BIN
/
patches
/
pagestream
/
3.0iupdate
/
macros.lha
/
OpenTemplate.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-02-19
|
8KB
|
265 lines
/* $VER: OpenTemplate.rexx 1.0e (19.02.96)
Copyright 1996 Soft-Logik Publishing Corporation
May not be distributed without Soft-Logik Publishing Corporation's express written permission */
OPTIONS RESULTS
ADDRESS 'PAGESTREAM'
/* Make sure rexx support is opened */
IF ~SHOW('L','rexxsupport.library') THEN
CALL ADDLIB('rexxsupport.library',0,-30)
/* Build the template list */
dPath="PageStream3:Macros/TemplateData"
Files=showdir(dPath,file,'|')
fLength=length(Files)
/* Check for valid template data files. Only .data are listed */
nList=0
DO WHILE fLength>0
cLength=pos('|',Files)
IF cLength=0 then DO
cLength=FLength+1
fLength=0
END
cFile=left(Files,cLength-1)
eFile=right(cFile,cLength-lastpos('.',cFile))
IF eFile='.data' THEN DO
cFile=left(cFile,cLength-6)
nList=nList+1
List.nList=cFile
END
IF FLength~=0 THEN Files=right(Files,fLength-cLength)
fLength=fLength-cLength
END
/* If there aren't any data files, alert the user and exit */
IF nList=0 THEN DO
allocarexxrequester '"Open Template Alert"' 358 65
alerthandle=result
addarexxgadget alerthandle EXIT 276 48 70 label "_Exit"
cancelhandle=result
addarexxgadget alerthandle TEXT 8 8 346 string '"There are no template data files in the"'
addarexxgadget alerthandle TEXT 8 22 346 string '"PageStream3:Macros/TemplateData directory."'
doarexxrequester alerthandle
choice=result
freearexxrequester alerthandle
EXIT
END
/* Sort the list alphabetically */
DO tick = 1 to nList - 1
nexttick = tick + 1
IF List.tick > list.nexttick THEN
DO
store = List.nexttick
List.nexttick = List.tick
DO bubpos = tick-1 to 1 by -1 WHILE (store < list.bubpos)
nexttick = bubpos + 1
List.nexttick = List.bubpos
END bubpos
bubpos = bubpos + 1
List.bubpos = store
END
END tick
/* Allocate and fill the template list */
allocarexxlist
tlisthandle=result
i=1
DO WHILE i<nList+1
addarexxlist tlisthandle List.i
i=i+1
END
/* Allocate template list requester */
allocarexxrequester '"Open Template"' 266 201
reqhandle=result
/* Add gadgets */
addarexxgadget reqhandle EXIT 12 184 70 label "_Open"
openhandle=result
addarexxgadget reqhandle EXIT 184 184 70 label "_Cancel"
cancelhandle=result
addarexxgadget reqhandle SCROLLIST 12 8 242 label list tlisthandle current 0 height 166
templatehandle=result
/*********************************
** Show template list requester **
*********************************/
doarexxrequester reqhandle
choice=result
/* Get list status */
getarexxgadget reqhandle templatehandle current
i=result+1
tFile=dPath||'/'||List.i||'.data'
docname='Untitled_'||List.i
/* set a flag so we know if it's avery labels */
avery=0
if List.i='AveryLabels' then avery=1
/* Unallocate requester and list */
freearexxlist tlisthandle
freearexxrequester reqhandle
/* If Cancel, then exit */
if choice=cancelhandle then signal CLEANUP
/* Open the template data file */
call open(tfHandle, tFile, 'R')
/* Find out how many page sizes there are */
line=readln(tfHandle)
parse var line numsizes .
/* Build a list of page sizes */
allocarexxlist
slisthandle=result
i=0
DO WHILE i<numsizes
line=readln(tfHandle)
addarexxlist slisthandle line
i=i+1
END
/*******************
** Page Size Loop **
*******************/
/* Why is this all in a loop? Because even though you can allocate a
requester, show a different one, then show the first one again, the size
of the first one changes to the size of the second one. Thus, it's best
to unallocate the requester after use and then re-allocate it. */
choice=morehandle
DO WHILE choice=morehandle
/* Allocate page size list requester */
if avery=0 then DO
allocarexxrequester '"Choose a page size"' 266 201
sizereqhandle=result
END
else DO
allocarexxrequester '"Choose an Avery® label style"' 266 201
sizereqhandle=result
END
/* Add gadgets */
addarexxgadget sizereqhandle EXIT 12 184 70 label "_Ok"
okhandle=result
addarexxgadget sizereqhandle EXIT 184 184 70 label "_Cancel"
cancelhandle=result
if avery=1 then DO
addarexxgadget sizereqhandle EXIT 98 184 70 label "_More"
morehandle=result
END
addarexxgadget sizereqhandle SCROLLIST 12 8 242 label list slisthandle current 0 height 166
pagesizehandle=result
/**********************************
** Show page size list requester **
**********************************/
doarexxrequester sizereqhandle
choice=result
/* Get list status */
getarexxgadget sizereqhandle pagesizehandle current
skipahead=result
/* Unallocate requester */
freearexxrequester sizereqhandle
if choice=morehandle then DO
allocarexxrequester '"Other label sizes"' 400 101
morereqhandle=result
addarexxgadget morereqhandle EXIT 318 84 70 label "_Ok"
addarexxgadget morereqhandle TEXT 8 8 384 border none string "'If you need a label size which is not listed'"
addarexxgadget morereqhandle TEXT 8 18 384 border none string "'here, send one sheet of the label to us and'"
addarexxgadget morereqhandle TEXT 8 28 384 border none string "'we will update this macro for you. Send to:'"
addarexxgadget morereqhandle TEXT 8 44 384 border none string "'Soft-Logik Publishing: Product Development'"
addarexxgadget morereqhandle TEXT 8 54 384 border none string "'315 Consort Drive'"
addarexxgadget morereqhandle TEXT 8 64 384 border none string "'St. Louis, MO 63011 USA'"
doarexxrequester morereqhandle
END
END
/* Unallocate list */
freearexxlist slisthandle
/* If Cancel, then exit */
if choice=cancelhandle then signal CLEANUP
/* Skip extra page size lines in data file */
i=0
DO WHILE i<skipahead
line=readln(tfHandle)
i=i+1
END
/* Get the page size info */
line=readln(tfHandle)
parse var line dum horz vert orient face margin.l margin.r margin.t margin.b columns gutter msys guides inc .
/* Skip extra page size lines in data file */
i=0
DO WHILE i<(numsizes-skipahead-1)
readln(tfHandle)
i=i+1
END
/* build the list of guides to create */
i=0
tempos=margin.t
horzguides=""
vertguides=""
DO WHILE i<guides
tempos=tempos+inc
horzguides=horzguides||' '||tempos
i=i+1
END
/* now add custom guide positions to the list */
hpos=pos('*h',line)
vpos=pos('*v',line)
horzguides=horzguides||substr(line,(hpos+2),(vpos-hpos-3))
vertguides=vertguides||right(line,(length(line)-vpos-1))
/************************
** Create the document **
************************/
'setmeasurements coordinate 'msys' sameas'
'newdocument '||docname
'newmasterpage "Default Master Page" '||horz vert orient face
'setmarginguides '||margin.l margin.r margin.t margin.b
'setcolumnguides '||columns gutter
if horzguides~="" then 'setguides mpg right horizontal at'||horzguides
if vertguides~="" then 'setguides mpg right vertical at'||vertguides
'setmeasurements coordinate 'msys' sameas relative sameas'
/************************
** Open the window **
************************/
'setdocumentstatus unchanged'
'openwindow View.1 page 1'
'displayguides ruler page show'
'displaygrid hide'
'snaptogrid off'
'snaptoguides on'
'setdocumentstatus unchanged'
signal cleanup
/**********************
** Clean up and exit **
**********************/
CLEANUP:
call close(tfHandle)
exit
return 0