View Raw SPL
/*****************************************************************************
* *
* SPLRELOAD.SPL Copyright (C) 2021 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: compiles and loads all SPL functions in a folder *
* *
* Revisions: 8 Dec 2010 RRR Creation *
* *
*****************************************************************************/
#if @HELP_SPLRELOAD
SPLRELOAD
Purpose: Recompiles and reloads one or more loaded SPL functions.
Syntax: SPLRELOAD("spl1", "spl2", ..., "splN")
"splN" - One or more strings. The names of the SPL functions
to reload.
Returns: An integer, the number of routines compiled and loaded.
Example:
W1: trapz(1..10)
splreload("trapz")
Recompiles the trapz SPL function.
Example:
splreload trapz
Same as above but uses the command line form.
Example:
splreload("trapz", "cumsum")
Recompiles the trapz snd cumsum SPL functions.
Remarks:
SPLRELOAD recompiles and reloads one or more previously
loaded SPL functions. This can be useful during the
development of SPLs where a function undergoes a test
and edit cycle.
Consider a custom SPL named MYSPL that resides in
a folder "D:\project\spl". If the file path is not
on the SPL search path, the function is first loaded
with:
splload("D:\project\spl\myspl")
Once loaded, if modifications are made, the function
can be recompiled and reloaded without having to
specify the source path with:
splreload("myspl")
or
splreload myspl
See Also:
Splcompile
Splload
Splread
Splwrite
#endif
/* recompile and load SPL functions */
splreload(argv)
{
local j, p, spl, cnt = 0, errcnt = 0, errmes = "";
if (argc < 1) error(sprintf("%s - SPL function name required", __FUNC__));
loop (j = 1..argc)
{
spl = getargv(j);
if (isstring(spl))
{
/* full path to SPL function */
p = splreload_fullname(spl);
if (strlen(p) > 0)
{
splload(p);
cnt++;
}
else
{
if (errcnt > 0)
{
errmes += "; ";
}
errmes += spl;
errcnt++;
}
}
}
if (strlen(errmes) > 0)
{
errmes += " not found";
error(sprintf("%s - %s", __FUNC__, errmes));
}
return(cnt);
}
/* return path to SPL function */
splreload_fullname(fun)
{
local path = "";
(path, fun, ext) = fileparts(fun);
path = isspl(fun) ? valuetype(fun, 1, 1) : which(fun, 0);
return(path);
}