View Raw SPL
/*****************************************************************************
* *
* CURPOSSET.SPL Copyright (C) 2013 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Sets cursor positions based on a source window *
* *
* Revisions: 17 Oct 2013 RRR Creation *
* *
*****************************************************************************/
#if @HELP_CURPOSSET
CURPOSSET
Purpose: Sets the cursor index positions of one or more windows based on a source window.
Syntax: CURPOSSET(srcwin, deswin1, deswin2, ..., deswinN)
srcwin - A window. The source window to obtain the X indices
of the first and second cursors.
deswinN - Optional, zero or more Windows. The target windows.
If not specified, defaults to the current window.
Returns: Nothing, the index positions of cursor 1 and cursor 2 of each
destination window is set to the positions of the source window.
Example:
W1: integ(gnorm(1000, 1/1000));curnput(100);curnput(700, 1, 2)
W2: integ(gnorm(1000, 1/1000));curposset(w1)
W1 contains 1000 point random series. The first cursor
position of W1 is set to index 100 and the second cursor
position is set to index 700. W2 contains a 1000 point random
series where the position of cursor 1 is set to index 100 and
the position of cursor 2 is set to index 700.
Example:
W1: integ(gnorm(1000, 1/1000));curnput(200);curnput(800, 1, 2)
W2: integ(gnorm(1000, 1/1000))
W3: integ(gnorm(1000, 1/1000))
curposset(w1, w2, w3)
W1 through W3 contain 1000 point random series. The first
cursor position of W1 is set to index 200 and the second cursor
position is set to index 800. The cursor positions of W2 and W3
are set to indices 200 and 800.
Remarks:
If no target window is specified, the cursor poistions of the
current window are set to the source window.
See CURLOCSET to set the X locations of cursors based on a source
window.
See CUREXTRACT to extract multiple windows based on the index
positions of the source window cursor position.
See Also:
Curnput
Curlocset
Curpos
Curextract
#endif
/* set cursor index position based on a source window */
curposset(srcwin, argv)
{
local pos1, pos2, cnt, i, deswin;
if (argc < 1)
{
error("curposset - source window required");
}
if (not(iswindow(srcwin)))
{
error("curposset - source window required");
}
/* source cursor position */
pos1 = curpos(srcwin, 1, 1);
pos2 = curpos(srcwin, 1, 2);
/* variable arg count */
cnt = argc - 1;
/* set target window cursor positions */
if (cnt > 0)
{
loop (i = 1..cnt)
{
deswin = getargv(i);
if (iswindow(deswin))
{
/* set destination cursor positions */
curnput(deswin, pos1, 1, 1);
curnput(deswin, pos2, 1, 2);
}
}
}
else
{
/* set current window cursor positions */
curnput(w0, pos1, 1, 1);
curnput(w0, pos2, 1, 2);
}
}