View Raw SPL
/*****************************************************************************
*                                                                            *
*   YSCALE.SPL   Copyright (C) 2018 DSP Development Corporation              *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Sets window Y autoscaling                                   *
*                                                                            *
*   Revisions:   13 Jul 2018  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/

#include 

#if @HELP_YSCALE

    YSCALE

    Purpose: Sets window Y autoscaling

    Syntax:  YSCALE(win, on_off)

              win    - an optional window, defaults to current window
              on_off - an integer 0:off 1:autoscale on (default 1)

    Returns: An integer, the previous Y autoscaling mode.

    Example:
             W1: Gsin(1000,1/1000,4);yscale(0);

             Turns off Y autoscaling in W1.

             yscale(W1, 1)

             Turns on Y autoscaling for W1.

    Remarks:
             YSCALE is useful for data in real time windows.

    See Also:
             Ascale
             Rttinit
             Xscale
#endif


/* turn Y autoscaling ON/OFF */
yscale(win, val)
{
        local exstyle, prevmode;

        /* autoscaling is a winexstyle bit */
        if (argc < 1)
        {
                return((winexstyle(W0) & EX_WIN_Y_NOSCALE) == 0);
        }
        else if (argc == 1)
        {
                if (iswindow(win))
                {
                        return((winexstyle(win) & EX_WIN_Y_NOSCALE) == 0);
                }
                else
                {
                        prevmode = (winexstyle(W0) & EX_WIN_Y_NOSCALE) == 0;

                        val = win == 0;
                        exstyle = winexstyle(W0);
                        
                        /* clear EX_WIN_Y_NOSCALE bit */
                        exstyle &= ~EX_WIN_Y_NOSCALE;

                        /* set EX_WIN_Y_NOSCALE bit */
                        if (val) exstyle |= EX_WIN_Y_NOSCALE;
                        
                        winexstyle(W0, exstyle);
                }
        }
        else
        {
                prevmode = (winexstyle(win) & EX_WIN_Y_NOSCALE) == 0;

                val = val == 0;
                exstyle = winexstyle(win);
                
                /* clear EX_WIN_Y_NOSCALE bit */
                exstyle &= ~EX_WIN_Y_NOSCALE;
                
                if (val) exstyle |= EX_WIN_Y_NOSCALE;
                
                winexstyle(win, exstyle);
        }

        return(prevmode);
}