[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Automated batch files



OK, here's a use for writing batch files from Xy. Every week, and most
weeks twice a week, I write a document in Xy and then have to convert it
to WordImPerfect. Robert gave us some nice batch files for doing the
conversion with the Hungarian filters, but one has to enter the file
name--indeed the fully qualified path name, unless one first CDs. Here's
how one can automate that from Xy, so that one just needs to close down
Xy (because one gets Out Of memory if one tries to do it within) and run
the resultant batch file. Here's the pseudocode, heavily documented,
because one must alter it to conform to one's own directory structure. I
have Xy and the Hungarian filters on drive D: (along with all other DOS
apps), and all my data on drive \E:
First, if you have Robert's xytowp.bat file, remove the two
error-trapping lines with a%1 and a%2 in them (necessary when an end user
might forget to enter the filenames, but that's just what we're
automationg) and resave it as xytowp.cod
With the file you want to convert saved and open, CL run d:xytowp.pgm,
which reads thus:
>; save the fully qualified path name to SG 01
BC new temp.txtXC ; create a temporary file
; write the contents of SG01 to it
CL CL CL CL DF EL DF ;move left four characters to get past the . and
extension (one could, and should, use XS for this, but I was having
problems, which I later discovered sprang from the fact that I had not
typed the period in the name when I named the file; will fix it next
week, but this works)
XD ;save the defined block, that is, the path and the filename
minus the extension, to SG02
; save ".wp" to SG03
>; save the filename, sans extension, plus .wp to SG04
BX default EP=0 Q2 ; turn off error prompts
BC abortXC ;get rid of temp.txt
BC ca d:xytowp.codXC ; call xytowp.cod
GT ; go to text
TF ; go to the top of the file
cd d:\xyhung{126}1\; insert the command to change directory to the dir
where the Hungarian filters are
BC ci /%1//XC ; change all instances of %1 to the original file's
fully qualified name
BC ci /%2//XC ; change all instances of %2 to the fully qualified
name of the output file
BC exist d:xytowp.batXC >BC ERNV d:xytowp.batXC ;
delete any old version of xytowp.bat without an error message
BC store d:xytowp.batXC; store the new version to xytowp.bat to
your XyWrite directory (assuming you're logged in there)
BX default EP=1,1,1,1,1,1,1Q2 ; turn error prompts back on

Here's the real code, but remember it must be edited to reflect your
directory structure:

XPLeNCODE v2.0
b-gin [xytowp.pgm]
{<}SX01,{<}VA$FP{>}{>}[BC_]new temp.txt[XC_]{<}PV01{>}[CL_][C
L_][CL_][CL_][DF_][EL_][DF_]{<}SV02{>}[XD_]{<}SV03,.wp{>} {<}
SV04,{<}PV02{>}{<}PV03{>}{>}[BX_]default EP=0 [Q2_][BC_]abort
[XC_][BC_]ca d:xytowp.cod[XC_][GT_][TF_]cd d:\xyhung~1\[cr|lf
][BC_]ci /%1/{<}PV01{>}/[XC_][BC_]ci /%2/{<}PV04{>}/[XC_][BC_
]exist d:xytowp.bat[XC_]{<}IF{<}ER{>}{>}{<}GLwrite{>}{<}EI{>}
[BC_]ERNV d:xytowp.bat[XC_]{<}LBwrite{>}[BC_]store d:xytowp.b
at[XC_][BX_]default EP=1,1,1,1,1,1,1[Q2_]
-nd
XPLeNCODE

Obviously, one could expand on this to offer choices of which format to
export to, and add all sorts of refinements.
Patricia