Flow control statements

One-line if statements are only allowed without an else clause.

Always start a new line after else, … else if … does not work as an expected elseif of other languages.

Write possible cases of a condition as separate ifs, not nested if - elseifs, unless an else clause containing unknown values is necessary.

values "iOption" OPTION_A, OPTION_B, OPTION_C
if iOption = OPTION_A then ...
if iOption = OPTION_B then ...
if iOption = OPTION_C then ...
! no other options

if GLOB_MODPAR_NAME = "A" then
    if GLOB_MODPAR_NAME = "B" then
    else ! anything else

When writing multi-line conditions in a conditional statement, the end-of-condition keyword should be on a new line, clearly separating the condition from the code block. When an else clause is present, make clear what else means with a comment.

if  iOption = OPTION_A |\
    iOption = OPTION_B \
else        ! OPTION_C | OPTION_D
while iPoint < (nPoints / 2) &\
      position < (length / 2) \

Avoid GOTO, use GOSUB, always return from subroutines. Only goto "MasterEnd" in master script is allowed.

When calling a subroutine conditionally, avoid the shortened forms:

if condition then goto label
if condition then gosub label

! instead of:
if condition then label
if condition goto label
if condition gosub label