DADiSP Worksheet Functions > Function Categories > Control Flow > GOTO

 

GOTO

Purpose:

Allows branching to labeled statements in SPL functions.

Syntax:

GOTO identifier:

identifier

-

A string. The label for the target of the GOTO.

Example:

In an SPL file, use the GOTO to jump to statements labeled by the identifier:

 

TestVal(a)
{
    if (a >= 1000)
    {
        goto BadValue;
    }
 
    return(1);
 
BadValue:
 
    return(99);
}

 

The SPL function, TestVal, returns a 1 if the value is less than 1000, and returns 99 if the value is greater than or equal to 1000. To avoid the GOTO, the function could be written as:

 

TestVal2(a)
{
    local b;
 
    if (a >= 1000)
    {
        b = 1;
    }
    else
    {
        b = 99;
    }
 
    return(b);
}

 

The function can be simplified further as:

 

TestVal3(a)
{
    local b;
 
    b = (a >= 1000) ? 1 : 99;
 
    return(b);
}

See Also:

BREAK

IF

SPL: Series Processing Language

WHILE