RE: macro help
Hi David.
Thanks a lot! This looks great (or, to be honest, it works great when I test it).
I then realized the even more embarrassing fact that I did not know how to apply a macro I had written to run
from a given file --- that is, a macro SomeMacro.edt that I invoke from a .tex file to run a sequence of
standard macros like 'Latex.edt' and 'dvi2ps.edt' --- in the new situation --- that is, when the input
file is the one whose name is in a register (e.g., %3). (I tried playing with the command WinExe, but clearly
did not stumble upon the correct way.) This is a very basic WinEdt issue, I am aware.
Best,
Nicolae
-----Original Message-----
From: David Huffer [mailto:David.Huffer <at> csosa.gov]
Sent: Monday, August 11, 2008 8:16 AM
To: winedt+list <at> wsg.net
Subject: RE: [WinEdt] macro help
On Friday, August 08, 2008 4:49, Nicolae Garleanu wrote:
> ...I would like to do the following with the
> help of a macro: if run from file
> XXX_YYY.tex, I would like it to take the
> name of the file, i.e., `XXX_YYY', strip the
> specified string `YYY' (alternatively,
> everything following the last `_') and
> replace it with another string '_ZZZ', after
> which it would run a set of commands on
> XXX_ZZZ.tex...What is the easiest way to
> generate the string `XXX_ZZZ.tex' and make
> sure that winedt runs the commands on a file
> with that name? Can you perhaps point to
> macros already distributed from which I can
> lift the appropriate pieces of code? (It
> would be faster and safer for me to modify
> existing code than writing some from
> scratch.)...
Something like this
DosToUnix("%p\%n%t",0);
Prompt("File name is %!0.");
FindInString( "%!0", "_*\.tex", 1, 2, 1);
ReplaceInString( "%!0", "_ZZZ\.tex", %!1, %!2, 1, 3);
Prompt("File name replaced is %!3.");
End;
is probably one of the easiest ways to generate the string
'XXX_ZZZ.tex' from XXX_YYY.tex. it replaces anything in the
filename following an underscore and before .tex with _ZZZ.
--
David