Skip to main content

END

Terminates a block of code or a program.

Synopsis

END

Arguments

None.

Description

The END statement has three uses:

  • As a clause terminator

  • As a statement terminator

  • As a routine terminator

Clause Terminator

When used as a clause terminator, the END keyword terminates execution of a block of code.

END is used as part of an IF...THEN statement, where it terminates execution of the block of code for the current clause of the IF...THEN statement.

END is used as part of a multiline LOCKED clause, ON ERROR clause, THEN clause, or ELSE clause, where it terminates execution of the block of code.

Block code clauses have specific line break requirements:

  • Each block code statement must appear on its own line.

  • The LOCKED, ON ERROR, THEN, or ELSE keyword cannot precede a block code statement on the same line.

  • The END keyword can appear on its own line, or can appear at the end of the final block code statement line. The code line END ELSE (concluding a multiline THEN clause and beginning an ELSE clause) is also valid.

The following are valid syntactic forms:

command args
THEN
statement1
statement2
END
ELSE
statement1
statement2
END
command args THEN
statement1
statement2 END
ELSE
statement1
statement2 END
command args THEN
statement1
statement2
END ELSE
statement1
statement2
END

Statement Terminator

The END keyword is used with another keyword in a few statements to indicate the end of the code encompassed by that statement. These uses are:

Routine Terminator

When used outside of a block structure clause END terminates routine or program execution. Commands following an END statement are not executed. If additional lines of code appear after the END statement, Caché (and all emulation modes), by default, generates an error: “Unexpected line outside of program”. You can set $OPTIONS IGNORE.EXTRA.LINES to ignore lines that appear after the END statement, rather than issuing an error message.

See Also

FeedbackOpens in a new tab