View Raw SPL
/*****************************************************************************
* *
* COMLABEL.SPL Copyright (C) 2015 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Labels a window with the series comment *
* *
* Revisions: 27 Apr 2015 RRR Creation *
* *
*****************************************************************************/
#if @HELP_COMLABEL
COMLABEL
Purpose: Labels a window with the series comment.
Syntax: COMLABEL(win, nodefault)
win - Optional. The target window. Defaults to the
current window.
nodefault - Optional. An integer, do not display default
comment.
0: Display default comment.
1: Do not display comment if it is the default
comment (default).
Example:
gnorm(1000, 1/1000);setvunits("V");setcomment("Channel 1");comlabel
Labels the Window with the series comment.
Remarks:
COMLABEL is useful when reading external tabular data
where each series comment is set to the column headers of
the table.
See COMXLABEL, COMYLABEL and COMXYLABEL to label the X and/or
Y axis with the series comment and units.
See Also:
Comxlabel
Comxylabel
Comylabel
Getlabel
Label
Setcolheader
Setcomment
Setxlabel Setylabel
Text
Wincaption
#endif
/* label window with comment */
comlabel(argv)
{
local nodefault, j, havewin;
nodefault = {};
havewin = 0;
/* get scalar args */
loop (j = 1..argc)
{
v = getargv(j);
if (isscalar(v))
{
if (isempty(nodefault))
{
nodefault = v;
}
}
else if (iswindow(v))
{
havewin = 1;
}
}
if (isempty(nodefault))
{
nodefault = 1;
}
if (havewin)
{
/* set each window */
loop (j = 1..argc)
{
v = getargv(j);
if (iswindow(v))
{
comlabel_set(v, nodefault);
}
}
}
else
{
/* set current window */
comlabel_set(w0, nodefault);
}
}
comlabel_set(w, nodefault)
{
local scom, dcom;
/* force window */
w = castwindow(w);
/* series comment */
scom = getcomment(w);
/* check if we do not use default comment */
if (nodefault)
{
/* default worksheet comment */
dcom = getwksattrib("defaultcomment");
if (strcmp(scom, dcom) == 0)
{
scom = "";
}
}
if (strlen(scom) > 0)
{
label(w, scom);
}
}
comlabel_error(errnum, errmes)
{
return(0);
}