There are a lot of times when I'm working on an E macro and need
to compile it to a different directory/filename, and then relink it
for testing. This has meant issuing 3 separate EPM commands, so I
made a couple changes to the supplied "relink" command to accomplish
this in one step.
"Relink2" takes two arguments:
relink2 <sourcename> <targetname>
and, to save some typing, if the first argument is the equals sign it
will automatically insert the current filename.
-----cut here-----
compile if WANT_ET_COMMAND
; Relink2 sourcename targetname
;
; A minor modification to the relink command.
; Compiles the source, writes it to the target, unlinks the target and links the
; target file again. A fast way to recompile/reload a macro under development from a
; source directory to a (different) target directory/filename without leaving the
; editor. Note that the unlink is necessary in case the module is already linked,
; else the link will merely reinitialize the previous version.
;
; If an equals sign is used for the source, the current filename is assumed.
;
defc relink2
parse arg sourcename targetname
if sourcename = '=' then -- If no name explicitly specified,
p = lastpos('.', .filename)
if upcase(substr(.filename,p))<>'.E' then
sayerror 'Not a .E file'
return
endif
sourcename = substr(.filename, 1, p-1) -- use current file.
if .modify then
's' -- Save it if changed.
if rc then return; endif
endif
endif
compile if EVERSION < 5
'et' sourcename targetname
compile else
'etpm' sourcename targetname -- This is the macro ETPM command.
compile endif
if rc then return; endif
unlink targetname
if RC & (RC <> -310) then sayerror RC; return; endif -- -310 = "Unlink: unknown module"
link targetname
compile if EVERSION < 5.20 -- EPM now does the sayerror internally
if RC<0 then
sayerror rc
endif
compile endif
compile endif -- WANT_ET_COMMAND
-----cut here-----
I simply added the code to my LINKCMDS.E file and re-compiled the
main macros. If you want to set up a separate RELINK2.EX file, you'll
need to replace the "defc relink2" line with "defmain" before
compiling and probably remove the "compile...compile endif
--WANT_ET_COMMAND" lines. Enjoy!
So sayeth,
Ken Arway