Destinations

<< Click to Display Table of Contents >>

Navigation:  User guide > Go to >

Destinations

All branches have a destination; the point in the CL script at which execution resumes after the branch has been taken.

Internal positions

IF, ELSE, UL, FILTER, CK (check) commands, and code loop branches, cause branches to implied destinations within the code, known as "internal positions". You do not need to specify these destinations.

A branch to an internal position may not span more than 32000 words of object code. To avoid this problem, avoid over-long IF or UL blocks and FILTER sections.

Positions

GO TO, GO OUT TO and READ commands require explicitly named destinations, and these are known in CL as "external positions", or more usually just "positions". The conventional programming term for positions is "labels", but this term has another meaning in CL.

A position is specified as the character at (@) followed by a name of 1-8 characters; if the name is not alphanumeric (containing only letters and numbers) it should be enclosed in quotes.

A position definition is made by a position command which consists of the position name followed by a comma.

Position commands may occur anywhere in the code, except within the range of an IF or UL command. It is not possible to branch into the range of an IF or UL command. A position command must be set for every position referred to, and no position may be defined twice in a given Stage. In Tables Stages the definition should follow all references, but in other Stages, backward branching is allowed.

A cross reference list of all positions in each stage, and where they are mentioned in the CL script, can be produced by using Run Control Parameter XREF .

Examples of branches:

ul $ival/>0, goto @noval,

ds $sval=$ival/1-5,>5,

@noval,

 

@again,

read $101-180 erec=@nomore,

di $sum=$sum+$123-124,

goto @again,

@nomore,

 

gooutto @doit,

d $150-159=$160-169,

gooutto @doit,

goto @alldone,

@doit,

d $brand=$150,$151,$159/1-5,

write,

goback,

@alldone,