STARTINDEX

Purpose:

Sets the starting index for an array in the current SPL function.

Syntax:

STARTINDEX(index)

index

-

Optional. An integer, the new starting index for array operations. Defaults to the current start index (usually 1).

Returns:

An integer, the previous starting index.

Example:

 

func1(a)
{
    local i, b;
 
    startindex(0);
    b = 0;
 
    for (i = 0; i < length(a); i++)
    {
        b += a[i] * i;
    }
 
    return(b);
}

 

This routine sets the starting index for array references to 0, such that the first value of variable a becomes a[0].

Remarks:

STARTINDEX is automatically reset to the configuration parameter SPL_START_INDEX (default 1) when the SPL function exits.

 

STARTINDEX only effects the current SPL routine, routines called by the current function are not effected.

 

STARTINDEX simplifies the development of routines where a starting index other than 1 is more natural for the algorithm.

See Also:

END

IDXTOX

XTOIDX