<html lang="en"> <head> <title>Statements - Untitled</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Untitled"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="prev" href="Evaluation.html#Evaluation" title="Evaluation"> <link rel="next" href="Functions-and-Scripts.html#Functions-and-Scripts" title="Functions and Scripts"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Statements"></a> <p> Next: <a rel="next" accesskey="n" href="Functions-and-Scripts.html#Functions-and-Scripts">Functions and Scripts</a>, Previous: <a rel="previous" accesskey="p" href="Evaluation.html#Evaluation">Evaluation</a>, Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a> <hr> </div> <h2 class="chapter">10 Statements</h2> <p><a name="index-statements-554"></a> Statements may be a simple constant expression or a complicated list of nested loops and conditional statements. <p><dfn>Control statements</dfn> such as <code>if</code>, <code>while</code>, and so on control the flow of execution in Octave programs. All the control statements start with special keywords such as <code>if</code> and <code>while</code>, to distinguish them from simple expressions. Many control statements contain other statements; for example, the <code>if</code> statement contains another statement which may or may not be executed. <p><a name="index-g_t_0040code_007bend_007d-statement-555"></a>Each control statement has a corresponding <dfn>end</dfn> statement that marks the end of the control statement. For example, the keyword <code>endif</code> marks the end of an <code>if</code> statement, and <code>endwhile</code> marks the end of a <code>while</code> statement. You can use the keyword <code>end</code> 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. <p>The list of statements contained between keywords like <code>if</code> or <code>while</code> and the corresponding end statement is called the <dfn>body</dfn> of a control statement. <ul class="menu"> <li><a accesskey="1" href="The-_003ccode_003eif_003c_002fcode_003e-Statement.html#The-_003ccode_003eif_003c_002fcode_003e-Statement">The <code>if</code> Statement</a> <li><a accesskey="2" href="The-_003ccode_003eswitch_003c_002fcode_003e-Statement.html#The-_003ccode_003eswitch_003c_002fcode_003e-Statement">The <code>switch</code> Statement</a> <li><a accesskey="3" href="The-_003ccode_003ewhile_003c_002fcode_003e-Statement.html#The-_003ccode_003ewhile_003c_002fcode_003e-Statement">The <code>while</code> Statement</a> <li><a accesskey="4" href="The-_003ccode_003edo_002duntil_003c_002fcode_003e-Statement.html#The-_003ccode_003edo_002duntil_003c_002fcode_003e-Statement">The <code>do-until</code> Statement</a> <li><a accesskey="5" href="The-_003ccode_003efor_003c_002fcode_003e-Statement.html#The-_003ccode_003efor_003c_002fcode_003e-Statement">The <code>for</code> Statement</a> <li><a accesskey="6" href="The-_003ccode_003ebreak_003c_002fcode_003e-Statement.html#The-_003ccode_003ebreak_003c_002fcode_003e-Statement">The <code>break</code> Statement</a> <li><a accesskey="7" href="The-_003ccode_003econtinue_003c_002fcode_003e-Statement.html#The-_003ccode_003econtinue_003c_002fcode_003e-Statement">The <code>continue</code> Statement</a> <li><a accesskey="8" href="The-_003ccode_003eunwind_005fprotect_003c_002fcode_003e-Statement.html#The-_003ccode_003eunwind_005fprotect_003c_002fcode_003e-Statement">The <code>unwind_protect</code> Statement</a> <li><a accesskey="9" href="The-_003ccode_003etry_003c_002fcode_003e-Statement.html#The-_003ccode_003etry_003c_002fcode_003e-Statement">The <code>try</code> Statement</a> <li><a href="Continuation-Lines.html#Continuation-Lines">Continuation Lines</a> </ul> </body></html>