Next: Functions and Scripts, Previous: Evaluation [Contents][Index]
Statements may be a simple constant expression or a complicated list of nested loops and conditional statements.
Control statements such as
while, and so on
control the flow of execution in Octave programs. All the control
statements start with special keywords such as
while, to distinguish them from simple expressions.
Many control statements contain other statements; for example, the
if statement contains another statement which may or may not be
Each control statement has a corresponding end statement that
marks the end of the control statement. For example, the
endif marks the end of an
if statement, and
endwhile marks the end of a
while statement. You can use
end anywhere a more specific end keyword is expected,
but using the more specific keywords is preferred because if you use
them, Octave is able to provide better diagnostics for mismatched or
missing end tokens.
The list of statements contained between keywords like
while and the corresponding end statement is called the
body of a control statement.