View Raw SPL
/*****************************************************************************
*                                                                            *
*   GETSYMBOLSIZE.SPL  Copyright (C) 2011 DSP Development Corporation        *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Returns the symbol size of a series                         *
*                                                                            *
*   Revisions:   31 Jan 2011  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/

#include 

#if @HELP_GETSYMBOLSIZE

    GETSYMBOLSIZE

    Purpose: Returns the symbol size of a series.

    Syntax:  GETSYMBOLSIZE(series, item)

              series - Optional, a series. Defaults to current window

                item - Optional, an integer. The series number if the 
                       target is a Window with more than one series.
                       Defaults to 1.

    Returns: An integer, the symbol size.

    Example:
             W1: 1..20;setsym(14);setsymbolsize(9)

             symsize = getsymbolsize(w1)

             W1 contains a 20 point series where a circle is used as a 
             symbol and the size is set to 9.

             symsize == 9

    Remarks:
             The SYMBOLSIZE is specified in terms of pixels.

             If size <= 0, the size is set to the SYMBOL_SIZE configuration 
             parameter.

    See Also:
             Getsymbol
             Getsymbolinterval
             Getsymboloffset
             Setsymbol
             Setsymbolinterval
             Setsymboloffset
#endif



/* get symbol size */
getsymbolsize(ser, item, member)
{
        local s, size;

        (s, item, member) = getsymbolsize_parse_args(ser, item, member);

        if (isscalar(s))
        {
                if (s == 0)
                {
                        /* current window */
                        size = (length > 0) ? getsymbol(3, item, member) : 0;
                        
                        return(size);
                }
                else
                {
                        s = castwindow(s);
                }
        }

        size = (length(s) > 0) ? getsymbol(s, 3, item, member) : 0;

        return(size);

}


getsymbolsize_parse_args(s, item, member)
{
        local winnum = 0;

        if (argc < 3)
        {
                if (argc < 2)
                {
                        if (argc < 1) s = refwindow(w0);
                        
                        item = -1;
                }
                
                member = -1;
        }

        if (isscalar(s))
        {
                member = item;
                item   = s;
                winnum = 0;
        }
        else if (iswindow(s))
        {
                winnum = getwnum(s);
        }
        else if (isarray(s))
        {
                winnum = refseries(s);
        }

        if (member < 0) member = 1;
        if (item < 0)   item   = 1;
        
        return(winnum, item, member);
}