View Raw SPL
/*****************************************************************************
* *
* VARLIST.SPL Copyright (C) 2018 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Returns a demilited string of the global variables *
* *
* Revisions: 3 Apr 2018 RRR Creation *
* *
*****************************************************************************/
#if @HELP_VARLIST
VARLIST
Purpose: Returns a delimited list of the global variables.
Syntax: VARLIST("separator", all)
"separator" - Optional. A string, the delimiter used to
separate variables names in the list. Defaults
to "," the comma delimiter.
all - Optional. An integer, the type flag.
0: show normal variables (default)
1: show hidden and normal variables
Returns: A sorted string of the currently loaded variables.
Example:
s = varlist();
t = strget(1, s, ",");
Variable S contains the comma separated variable list and T\
contains the first variable name in the list.
Example:
viewtext(varlist(strescape("\n")));
Displays the loaded variables in a pop-up box.
Remarks:
VARLIST returns an alphabetically sorted list of the loaded
variables.
See Also:
Maclist
Objectlist
Spllist
Splwrite
Strsort
Strfile
#endif
/* get separated list of loaded variables */
varlist(separator, all)
{
local list;
if (argc < 2)
{
if (argc < 1)
{
separator = ",";
}
if (isscalar(separator))
{
all = separator;
separator = ",";
}
else
{
all = 0;
}
}
list = objectlist(12, 0, 1, all);
if (strescape(separator) != strescape("\n"))
{
list = strrep(list, strescape("\n"), strescape(separator));
}
return(list);
}