View Raw SPL
/*****************************************************************************
* *
* CURXEXTRACT.SPL Copyright (C) 2012 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Extract from a source window based on cursor locations *
* *
* Revisions: 20 Jul 2012 RRR Creation *
* *
*****************************************************************************/
#if @HELP_CURXEXTRACT
CURXEXTRACT
Purpose: Extract series from a source window based on cursor X location.
Syntax: CURXEXTRACT(srcwin, deswin1, deswin2, ..., deswinN)
srcwin - A window. The source window to obtain the X locations
of the first and second cursors.
deswinN - Optional, zero or more Windows. The target windows.
If not specified, defaults to the current window.
Returns: A series if no target window is specified else the result of
each extraction is placed into the target windows.
Example:
W1: integ(gnorm(1000, 1/1000));curput(0.2);curput(0.4, 2)
W2: curxextract(w1)
W1 contains 1000 point random series. The first cursor
location of W1 is set to 0.2 and the second cursor
location is set to 0.4. W2 contains the extracted series
in W1 from 0.2 to 0.4.
Example:
W1: integ(gnorm(1000, 1/1000));curput(0.2);curput(0.4, 2)
W2: integ(gnorm(1000, 1/1000))
W3: integ(gnorm(1000, 1/1000))
curxextract(w1, w2, w3)
W1 through W3 originally contain 1000 point random series.
The first cursor location of W1 is set to 0.2 and the second
cursor location is set to 0.4. The series in W2 and W3 are
extracted from 0.2 to 0.4.
Remarks:
If no target window is specified, the source window is
extracted into the current window.
The source window can also be a target window.
See CUREXTRACT to extract multiple windows based on the
indices of the source window cursors.
See Also:
Curextract
Extract
Extractwin
Xextract
Xextractwin
#endif
/* extract based on cursor locations */
curxextract(src, argv)
{
local cnt, loc1, loc2, i, w;
if ((cnt = argc) < 1)
{
error("curxextract - source window required")
}
if (not(iswindow(src)))
{
error("curxextract - source window required")
}
/* get cursor positions in terms of x values */
loc1 = curloc(src, 1, 1);
loc2 = curloc(src, 1, 2);
if (loc1 != 0.0 || loc2 != 0.0)
{
if (cnt == 1)
{
/* no target, return extracted series */
return(xextract(src, loc1, loc2));
}
loop (i = 1..(cnt - 1))
{
w = getargv(i);
if (iswindow(w))
{
if (not(isempty(w)))
{
/* extract based on X values */
setwform(w, sprintf("xextract(curr, %1.16g, %1.16g)", loc1, loc2));
}
}
}
}
}