View Raw SPL
/*****************************************************************************
*                                                                            *
*   SETVGRID.SPL Copyright (C) 2010 DSP Development Corporation              *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:       Randy Race                                                 *
*                                                                            *
*   Synopsis:     Sets the vertical grid style and color                     *
*                                                                            *
*   Revisions:     7 Sep 2010  RRR  Creation                                 *
*                                                                            *
*****************************************************************************/


#if @HELP_SETVGRID

    SETVGRID

    Purpose: Sets the style and color of the vertical (X) grids

    Syntax:  SETVGRID(win, style color)

              win - Optional. The target window. Defaults to the current
                    window.

             style - An integer, the grid style:
                        0: Off
                        1: Solid
                        2: Dashed
                        3: Dotted

             color - Optional. An integer, the grid color. Defaults to
                     the current grid color.

    Returns: Nothing, the vertical grids are set.

    Example:
             W1: gnorm(100, 1);setvgrid(1);

             Sets the vertcal grids in W1 to solid in the current grid color.

    Example:
             W1: gnorm(100, 1);setvgrid(3, black);

             Sets the vertical grids in W1 to dotted in black.

    Remarks:
             SETVGRID sets the vertical grids only.

             Use SETVGRID(0) to turn off grids.

             See SETHVGRID to set both the horizontal and vertical grids.

    See Also:
             Griddash
             Griddot
             Gridhv
             Gridsol
             Sethgrid
             Sethvgrid
#endif


/* sets the vertical (x) grid style */
setvgrid(w, style, color)
{
        (w, style, color) = setvgrid_parse_args(w, style, color);

        /* target window */
        w = castwindow(w);

        /* grid style */
        setgridstyle(w, 1, style);

        /* grid color */
        gridcolor(w, color);
}


setvgrid_parse_args(w, style, color)
{
        if (argc < 3)
        {
                if (argc < 2)
                {
                        if (argc < 1) w = -1;
                        
                        style = -1;
                }
                
                color = -1;
        }
        if (isscalar(w))
        {
                if (w < 0)
                {
                        w = 0;
                }
                else
                {
                        color = style;
                        style = w;
                        w     = 0;
                }
        }
        else
        {
                w = getwnum(w);
        }

        if (style < 0) style = getgridstyle(castwindow(w), 1);
        if (color < 0) color = getgridcolor(castwindow(w));

        return(w, style, color);
}