View Raw SPL
/*****************************************************************************
*                                                                            *
*   GETXRIDX.SPL  Copyright (C) 2010 DSP Development Corporation             *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Returns the rightmost index of a series in a window         *
*                                                                            *
*   Revisions:    2 Dec 2010  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/

#if @HELP_GETXRIDX

    GETXRIDX

    Purpose: Returns the rightmost index of a series displayed in a Window.

    Syntax:  GETXRIDX(window)

               window - Optional, a Window. Defaults to the current Window.

    Returns: An integer.

    Example:
             W1: 1..0.1..10;setx(5, 9);

             ridx = getxridx(W1);
             rval = W1[ridx]

             ridx == 81
             rval == 9.0

             indicating that the 81st sample of W1 is the rightmost sample and
             the associated Y value is 9.0.

    Remarks:
             GETXRIDX returns the index of the rightmost displayed series.

             See GETYR to return the rightmost Y value of the displayed
             series.

    See Also:
             Idxtox
             Getxl
             Getxlidx
             Getxr
             Getyl
             Getyr
             Xtoidx
#endif


/* get rightmost series index */
getxridx(win)
{
        local xr;

        if (argc < 1) win = refwindow(w0);

        /* convert rightmost X value to series index */
        xr = xtoidx(win, getxr(win));
        
        return(xr);
}