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

#if @HELP_GETXLIDX

    GETXLIDX

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

    Syntax:  GETXLIDX(window)

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

    Returns: An integer, the leftmost series index.

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

             lidx = getxlidx(W1);
             lval = W1[lidx]

             lidx == 41
             lval == 5.0

             indicating that the 41st sample of W1 is the leftmost sample and
             the associated Y value is 5.0.

    Remarks:
             GETXLIDX returns the index of the leftmost displayed series.

             See GETYL to return the leftmost Y value of the displayed
             series.

    See Also:
             Getxl
             Getxr
             Getxridx
             Getyl
             Getyr
             Xtoidx
#endif


/* get leftmost series index */
getxlidx(win)
{
        local xl;

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

        /* convert leftmost X value to series index */
        xl = xtoidx(win, getxl(win));
        
        return(xl);
}