View Raw SPL
/*****************************************************************************
*                                                                            *
*   SETYAUTOSCALE.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_SETYAUTOSCALE

    SETYAUTOSCALE

    Purpose: Sets window Y autoscaling

    Syntax:  SETYAUTOSCALE(win, on_off)

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

    Returns: Nothing

    Example:
             W1: gsin(1000,1/1000,4);setyautoscale(0);

             Turns off Y autoscaling in W1.

    Example:
             setyautoscale(W1, 1)

             Turns on Y autoscaling for Window 1.

    Remarks:
             SETYAUTOSCALE is useful for data in real time Windows.

    See Also:
             Rttinit
             Getautoscale
             Getxautoscale
             Getyautoscale
             Setautoscale
             Setxautoscale
#endif


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

        /* 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
                {
                        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
        {
                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);
        }
}