Xbasic

RETURN

Syntax

RETURN [return_value]

Arguments

return_valueAny Type

The value to return from the function. The value type should match the declared return type for the function.

Description

RETURN causes an unconditional exit from a user-defined function and return a value.

Discussion

The RETURN keyword is used to exit from a user-defined function. It can be used to return a value from the function.

If no value is specified, RETURN behaves the same as EXIT FUNCTION.

Example

This function will be terminated if the second argument is 0.

FUNCTION divide as N(arg1 as N, arg2 as N)
    IF arg2 = 0 THEN
        ui_msg_box("Error","Cannot divide by zero")
        RETURN 0
    END IF
    divide = arg1/arg2
END FUNCTION

See Also