User Tools

Site Tools


statement_execution_sequence.htm
Navigation:  Language Reference > 2 - Program Source Code Format > Program Format >====== Statement Execution Sequence ====== Previous pageReturn to chapter overviewNext page

In the CODE section of a Clarion program, statements are normally executed line-by-line, in the sequence in which they appear in the source module. Control statements and procedure calls are used to modify this execution sequence.

PROCEDURE calls modify the execution sequence by branching to the called procedure and executing the code contained in it. Control returns to the executable statement following the procedure call when a RETURN statement is executed in the called procedure, or there are no more statements in the called procedure to execute, returning the value (if the PROCEDURE returns a value).

Control structures–IF, CASE, LOOP, ACCEPT, and EXECUTE–change the execution sequence by evaluating expressions. The control structure conditionally executes statements contained within the structure based on the evaluation of the expression(s) in the structure. ACCEPT is also a loop-type of structure, but does not evaluate any expression.

Branching also occurs with the GOTO, DO, CYCLE, BREAK, EXIT, and RETURN statements. These statements immediately and unconditionally alter the normal execution sequence.

The START procedure begins a new execution thread, unconditionally branching to that thread at the next instance of ACCEPT following the START. However, the user may choose to activate another thread by clicking the mouse on the other thread's active window.

Example:

PROGRAM

MAP

ComputeTime PROCEDURE(*GROUP) !Passing a group parameter

MatchMaster PROCEDURE         !Passing no parameters

END

ParmGroup GROUP               !Declare a group

FieldOne   STRING(10)

FieldTwo   LONG

      END

CODE                         !Begin executable code

FieldTwo = CLOCK()           !Executes 1st

ComputeTime(ParmGroup)       !Executes 2nd, passes control to procedure

MatchMaster                  !Executes after procedure executes fully

statement_execution_sequence.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1