User Tools

Site Tools

Navigation:  Language Reference > 12 - Execution Control > Execution Control Statements >====== RETURN (return to caller) ====== Previous pageReturn to chapter overviewNext page


RETURN [expression]


expression The expression passes the return value of a PROCEDURE prototyped to return a value back to the expression in which the PROCEDURE was used. This may be NULL if the PROCEDURE returns a reference.

The RETURN statement terminates a PROGRAM or PROCEDURE and passes control back to the caller. When RETURN is executed from the CODE section of a PROGRAM, the program is terminated, all files and windows are closed, and control is passed to the operating system.

RETURN is required in a PROCEDURE prototyped to return a value and optional in a PROGRAM or PROCEDURE which does not return a value. If RETURN is not used in a PROCEDURE or PROGRAM, an implicit RETURN occurs at the end of the executable code. The end of executable code is defined as the end of the source file, or the beginning of another PROCEDURE or ROUTINE.

RETURN from a PROCEDURE (whether explicit or implicit) automatically closes any local APPLICATION, WINDOW, REPORT, or VIEW structure opened in the PROCEDURE. It does not automatically close any Global or Module Static APPLICATION, WINDOW, REPORT, or VIEW. It also closes and frees any local QUEUE structure declared without the STATIC attribute.

An expression in parentheses is also a valid expression by the syntax definition of expressions. If a variable is enclosed in parentheses, it is dereferenced to a value of that variable and then casted to one of the base types. Regarding the use of parenthesis with RETURN, if a function has a variable or reference RETURN type, the returned variable used in the RETURN statement must not be enclosed in parentheses.


IF Done#

RETURN                     !Quit when done


DayOfWeek PROCEDURE(Date)    !Procedure to return the day of the week

RetVal  STRING(9)


EXECUTE Date % 7            !Determine what day of week Date is

 RetVal = 'Monday'

 RetVal = 'Tuesday'

 RetVal = 'Wednesday'

 RetVal = 'Thursday'

 RetVal = 'Friday'

 RetVal = 'Saturday'


 RetVal = 'Sunday'


RETURN RetVal               !and RETURN the correct day string

See Also:


PROCEDURE Return Types

return_return_to_caller_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)