DADiSP Worksheet Functions > Function Categories > Control Flow > ERROR

 

ERROR

Purpose:

Aborts an SPL routine and optionally displays a message.

Syntax:

ERROR("message", "title", guiflag, errval)

"message"

-

An optional string. Error message to display.

"title"

-

An optional string. The title of the message box if a GUI is displayed.

guiflag

-

Optional. An integer, the display method:

-1:

Use system default value (default).

 0:

Display error message in lower message area.

 1:

Display message using a pop-up GUI box.

errval

-

Optional. An integer. The returned error value used to propagate errors to calling routines. Normally not specified. Defaults to 0.

Returns:

Nothing, the SPL routine that invoked the error function terminates processing.

Example:

invnum(x)
{
    if (x == 0)
    {
        error("invnum - input must be non-zero");
    }
    else return(1/x);
}

 

invnum(0)

 

aborts and displays the message:

 

invnum - input must be non-zero

 

sqrt(invnum(0))

 

aborts and displays the message:

 

invnum - input must be non-zero

Remarks:

ERROR aborts further SPL processing. As shown in the second example, nested functions or SPL routines also terminate as a result of ERROR.

 

If guiflag is -1, the flag is set to the configuration parameter SPL_GUI_ERROR.

 

See SPL Error Handlers for information on handling errors in SPL functions.

See Also:

ECHO

FPRINTF

PRINTF

SPRINTF

WAITKEY