View Raw SPL
/*****************************************************************************
*                                                                            *
*   GETYL.SPL  Copyright (C) 2010 DSP Development Corporation                *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Returns the Y value of the leftmost displayed series        *
*                                                                            *
*   Revisions:    2 Dec 2010  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/

#if @HELP_GETYL

    GETYL

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

    Syntax:  GETYL(window)

             (yl, idx) = GETYL(window)

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

    Returns: A real or complex value, the leftmost Y value.

             (yl, idx) = GETYR(window) returns the Y value and index.
             
    Example:
             W1: 1..0.1..10;setx(5, 9);

             yl = GETYL(W1);

             yl == 5.0

             indicating that the leftmost sample of the series displayed in
             W1 has a value of 5.0.

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

             (yl, idx) = GETYL(W1);

             yl  == 5.0
             idx == 41

             indicating that the leftmost sample of the series displayed in
             W1 has a value of 5.0 and occurs at index 41.

    Remarks:
             GETYL returns Y value of the leftmost displayed series.

    See Also:
             Idxtox
             Getxl
             Getxr
             Getxridx
             Getyr
             Xtoidx
#endif


/* get leftmost series value */
getyl(win)
{
        local yl, idx;

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

        /* convert rightmost X value to series value */
        idx = getxlidx(win);
        yl  = getpt(win, idx);

        if (outargc > 1)
        {
                /* value and index */
                return(yl, idx);
        }
        else
        {
                return(yl);
        }
}