RETURN

Ends execution of an application program and returns to the "previous" command level.

Syntax

RETURN [TO procedure]

Parameters

procedure

The name of a procedure. Must be an ancestor (i.e., the "parent", "grandparent", "great-grandparent", etc.) of the current procedure.

Comments

The RETURN command stops execution of the current procedure.

If a TO clause is omitted, execution control returns to the calling procedure (the "parent") at the command immediately following the call that started execution of the current procedure.

If a TO clause is used, execution control returns to the specified procedure, provided that it is found along the chain of procedures that are "ancestors" of the current procedure. Execution resumes at the command immediately following the call that started execution of the offspring procedure in the current chain. If the specified procedure is not found along the chain of ancestors, execution control returns to the main prompt level.

If the RETURN command is entered at the main prompt level, the application session is ended (just as if a BYE command had been issued).

Example

To return control from the current procedure to the calling procedure when a FIND command returns an empty result set, enter

find all Employees where Salary > 10000
if $setcount = 0
 return
endif

To return to a grandparent procedure if a FIND command returns an empty result set, enter

01 procedure Grandparent ( )
02  Parent ( )        % goes to line 20
   ... more commands ...
18 endprocedure
19 %-------------------------------------------------
20 procedure Parent ( )
21  Child ( )        % goes to line 35
   ... more commands ...
33 endprocedure
34 %-------------------------------------------------
35 procedure Child ( )
36  find all Employees where Salary > 10000
37  if $setcount = 0
38   return to Grandparent  % goes to line 03
39  endif
   ... more commands ...
50 endprocedure

 

Related Topics