ARGV

Purpose:

Specifies variable arguments in an SPL routine.

Syntax:

ARGV

Returns:

Nothing.

Example:

/* maximum of one or more inputs */
vmax(argv)
{
    local i, s;
 
    /* 0 or 1 arg case */
    if (argc < 2)
    {
        if (argc < 1)
        {
            s = maxval();
        }
        else
        {
            s = maxval(getargv(1));
        }
    }
    else
    {
        /* initialize */
        s = maxval(getargv(1), getargv(2));
 
        /* compare input args */
        loop (i = 3..argc)
        {
            s = maxval(s, getargv(i));
        }
    }
    
    return(s);
}

 

ARGV in the argument list of an SPL routine specifies a variable number of input arguments. The above routine returns the maximum of two or more expressions.

 

ARGC returns the total number of input arguments and GETARGV obtains a particular variable argument.

Remarks:

ARGV can be used in combination with specified arguments. For example:

 

func1(a, b, c, argv)
{
}

 

Creates a function that accepts 3 specified arguments and any number of variable arguments.

See Also:

ARGC

GETARGV

ISVARIABLE

OUTARGC

RETURN