Return Statement

Terminates execution of the procedure in which it appears and returns control to the calling code. If the procedure is a function, the Return statement specifies the value to be returned as the result of calling the function.

Syntax

Return [ expression ]

Comments

For a subroutine procedure (where the Returns type of the procedure is Void), the Return statement must not have a return value expression and a Return statement at the end of the subroutine is optional.

For a function procedure (where the Returns type of the procedure is not Void), every Return statement in the function must have a return value expression. In addition, every possible path of execution through the function code must end in Return statement. The expression must be assignment compatible with the Returns type of the function. The expression value is converted to the Returns type of the function and used as the value of the function call in the calling code.

Example

Procedure CheckStatus (): Void

{

If iStatus <> PASS Then

sStatus=""

Return

Endif

sStatus=asStatus[iStatus]

}

Procedure ModuleTypeString(enType): String

----------------------------------------------------------

enType: Val Long

{

! Return string for module type

SELECT enType

CASE amoduleTypeDriver

RETURN "Driver"

CASE amoduleTypeProgram

RETURN "Program"

CASE amoduleTypeSystem

RETURN "System"

CASE ELSE

RETURN "*** Unknown module type ***"

ENDSELECT

}

See Also

Function Call, Subroutine Call