View Raw SPL
/* for XY panel, 2 series and column list */
_s2clist (ser1, col1, ser2, col2, ser3, col3, xycollst, xyintrp, nc1, nc2, nc3, xyitv, xyauto, xydtf, xylab, startwin, verbose)
{
local dlen1, dlen2, dlen3, start, i, form, wn, status, collist;
dlen1 = eval(sprintf("length(%s)", ser1));
dlen2 = eval(sprintf("length(%s)", ser2));
dlen3 = (xydtf) ? eval(sprintf("length(%s)", ser3)) : 1;
if (dlen1 > 0 && dlen2 > 0 && dlen3 > 0)
{
start = getwnum(castwindow(startwin));
/* load into multiple windows */
start = castint(startwin);
if (xydtf)
{
/* convert collist to series */
if (strlen(xycollst) == 0 || strcmp(xycollst, _allstr) == 0)
{
collist = 1..eval(sprintf("numcols(%s)", ser3));
if (strcmp(ser1, ser3) == 0)
{
/* remove date column */
collist = delete(collist, collist == numstr(col1));
}
if (strcmp(ser2, ser3) == 0)
{
/* remove time column */
collist = delete(collist, collist == numstr(col2));
}
}
else
{
collist = eval(sprintf("{%s}", xycollst));
}
}
else
{
/* convert collist to series */
if (strlen(xycollst) == 0 || strcmp(xycollst, _allstr) == 0)
{
collist = 1..eval(sprintf("numcols(%s)", ser2));
if (strcmp(ser1, ser2) == 0)
{
/* remove time column */
collist = delete(collist, collist == numstr(col1));
}
}
else
{
collist = eval(sprintf("{%s}", xycollst));
}
}
nc = length(collist);
if (verbose)
{
/* see if we need to add windows */
status = _s2clist_dwin(start, nc);
}
if (status >= 0 && numwin > 0)
{
if (start <= 0) start = 1;
/* limit to number of worksheet windows */
nc = min(nc, numwin - start + 1);
wn = start;
/* target window(s) */
winlist = (nc > 1) ? sprintf("w%d..w%d", start, start + nc - 1) :
sprintf("w%d", start);
/* disable plotting, clear windows, load and plot */
eval(sprintf("clear(%s);lines(%s)", winlist, winlist));
/* now load each column into a window */
loop (i = 1..nc)
{
col2 = xydtf ? col2 : sprintf("%d", collist[i]);
col3 = xydtf ? sprintf("%d", collist[i]) : col3;
form = _s2c2(ser1, col1, ser2, col2, ser3, col3, xyintrp, nc1, nc2, nc3, xyitv, xyauto, xydtf);
if (xylab)
{
form = sprintf("%s;comlabel()", form);
}
form = sprintf("W%d := (%s)", wn, form);
eval(form);
wn++;
}
}
}
}
/* add windows if necessary */
_s2clist_dwin(start, numser)
{
local status = 1, num, numadd, maxwindows;
if (numwin() == 0)
{
/* no windows */
numadd = numser;
}
else
{
/* offset from starting window */
num = numwin() - start + 1;
numadd = numser - num;
}
/* number of allowed windows */
maxwindows = numwin(-1);
if (numadd + numwin() > maxwindows)
{
numadd = maxwindows - numwin();
}
if (numadd > 0)
{
status = message(sprintf(_xystr_fcc,
numser, numadd), 7);
if (status == 1)
{
eval(sprintf("addwin(W%d, %d)", start, numadd));
}
}
return(status);
}