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

#include 

#if @HELP_XSCALE

    XSCALE

    Purpose: Sets window X autoscaling

    Syntax:  XSCALE(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 X autoscaling mode.

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

             Turns off X autoscaling in W1.

             xscale(W1, 1)

             Turns on X autoscaling for W1.

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

    See Also:
             Ascale
             Rttinit
             Yscale
#endif


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

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

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

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

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

        return(prevmode);
}