View Raw SPL
/*****************************************************************************
* *
* ADDSPLPATH.SPL Copyright (C) 2017 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Adds custom paths to the SPL search path *
* *
* Revisions: 25 Oct 2017 RRR Creation *
* *
*****************************************************************************/
#if @HELP_ADDSPLPATH
ADDSPLPATH
Purpose: Adds a new path to the SPL search path.
Syntax: ADDSPLPATH("path", subdirs)
"path" - A string, the path to add to the SPL search path.
subdirs - Optional. An integer, include sub-folders flag.
Defaults to 1, include all sub-folders of "path".
Returns: A string, the new full SPL search path.
Example:
addsplpath("C:\myfolder")
Adds the path "C:\myfolder" to the current SPL search path.
All sub-folders within "C:\myfolder" are included.
Example:
addsplpath("C:\myfolder;D:\new\folder", 0)
Adds the paths "C:\myfolder" and "D:\new\folder" to the
current SPL search path. Sub-folders within "C:\myfolder"
and D:\new\folder" are not included.
Remarks:
The SPL search path is searched for SPL functions, modules
and user menus. ADDSPLPATH extends the search path with
custom additions.
Multiple paths are delimited with the ";" character.
See RESETSPLPATH to remove custom paths from the SPL
search path.
See Also:
GETSPLPATH
RESETSPLPATH
#endif
/* add user path to SPL search path */
addsplpath(path, subdirs)
{
local spath;
if (argc < 2)
{
if (argc < 1) path = "";
subdirs = 1;
}
if (strlen(path) > 0)
{
if (subdirs)
{
/* add subdirs for each component */
path = addsplpath_subdirs(path);
}
/* get current user path additions */
spath = getconfig("splpath");
if (strlen(spath) > 0)
{
/* append existing components */
path += ";" + spath;
}
/* set additions and get new full search path */
path = setsplpath(path);
}
return(path);
}
/* find subdirs for each path component */
addsplpath_subdirs(path)
{
local p, allpaths = "", j = 1;
while (1)
{
/* path component */
p = strget(j, path, ";");
if (strlen(p) <= 0)
{
break;
}
/* newline delimited list of subdirs */
sdirs = objectlist(8, 0, 1, 1, p);
/* convert delimiters to ";" */
sdirs = strrep(sdirs, strescape("\n"), ";");
/* append */
allpaths += p + ";" + sdirs;
j++;
}
return(allpaths);
}