Mercurial > octave-nkf
diff doc/interpreter/stmt.txi @ 9038:fca0dc2fb042
Cleanup documentation files stmt.texi and func.texi
Spellcheck
Style check (especially two spaces after period)
Info menu now uses @code macro when describing code statements such as while, for, if, etc.
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Sun, 22 Mar 2009 11:15:35 -0700 |
parents | eb63fbe60fab |
children | 923c7cb7f13f |
line wrap: on
line diff
--- a/doc/interpreter/stmt.txi Sun Mar 22 08:41:49 2009 -0700 +++ b/doc/interpreter/stmt.txi Sun Mar 22 11:15:35 2009 -0700 @@ -47,19 +47,19 @@ @dfn{body} of a control statement. @menu -* The if Statement:: -* The switch Statement:: -* The while Statement:: -* The do-until Statement:: -* The for Statement:: -* The break Statement:: -* The continue Statement:: -* The unwind_protect Statement:: -* The try Statement:: +* The @code{if} Statement:: +* The @code{switch} Statement:: +* The @code{while} Statement:: +* The @code{do-until} Statement:: +* The @code{for} Statement:: +* The @code{break} Statement:: +* The @code{continue} Statement:: +* The @code{unwind_protect} Statement:: +* The @code{try} Statement:: * Continuation Lines:: @end menu -@node The if Statement +@node The @code{if} Statement @section The @code{if} Statement @cindex @code{if} statement @cindex @code{else} statement @@ -208,7 +208,7 @@ using the indentation to show how Octave groups the statements. @xref{Functions and Scripts}. -@node The switch Statement +@node The @code{switch} Statement @section The @code{switch} Statement @cindex @code{switch} statement @cindex @code{case} statement @@ -216,7 +216,7 @@ @cindex @code{endswitch} statement It is very common to take different actions depending on the value of -one variable. This is possible using the @code{if} statement in the +one variable. This is possible using the @code{if} statement in the following way @example @@ -231,8 +231,8 @@ @noindent This kind of code can however be very cumbersome to both write and -maintain. To overcome this problem Octave supports the @code{switch} -statement. Using this statement, the above example becomes +maintain. To overcome this problem Octave supports the @code{switch} +statement. Using this statement, the above example becomes @example switch (X) @@ -247,7 +247,7 @@ @noindent This code makes the repetitive structure of the problem more explicit, -making the code easier to read, and hence maintain. Also, if the +making the code easier to read, and hence maintain. Also, if the variable @code{X} should change its name, only one line would need changing compared to one line per case when @code{if} statements are used. @@ -270,16 +270,16 @@ @end example @noindent -where @var{label} can be any expression. However, duplicate +where @var{label} can be any expression. However, duplicate @var{label} values are not detected, and only the @var{command_list} -corresponding to the first match will be executed. For the +corresponding to the first match will be executed. For the @code{switch} statement to be meaningful at least one @code{case @var{label} @var{command_list}} clause must be present, while the @code{otherwise @var{command_list}} clause is optional. If @var{label} is a cell array the corresponding @var{command_list} is executed if @emph{any} of the elements of the cell array match -@var{expression}. As an example, the following program will print +@var{expression}. As an example, the following program will print @samp{Variable is either 6 or 7}. @example @@ -299,7 +299,7 @@ @c Strings can be matched One advantage of using the @code{switch} statement compared to using -@code{if} statements is that the @var{label}s can be strings. If an +@code{if} statements is that the @var{label}s can be strings. If an @code{if} statement is used it is @emph{not} possible to write @example @@ -328,7 +328,7 @@ @subsection Notes for the C programmer The @code{switch} statement is also available in the widely used C -programming language. There are, however, some differences +programming language. There are, however, some differences between the statement in Octave and C @itemize @bullet @@ -363,7 +363,7 @@ @end example @noindent -particularly for C programmers. If @code{doit()} should be executed if +particularly for C programmers. If @code{doit()} should be executed if @var{foo} is either @code{1} or @code{2}, the above code should be written with a cell array like this @@ -377,7 +377,7 @@ @end example @end itemize -@node The while Statement +@node The @code{while} Statement @section The @code{while} Statement @cindex @code{while} statement @cindex @code{endwhile} statement @@ -446,7 +446,7 @@ body; but using one makes the program clearer unless the body is very simple. -@node The do-until Statement +@node The @code{do-until} Statement @section The @code{do-until} Statement @cindex @code{do-until} statement @@ -493,7 +493,7 @@ body; but using one makes the program clearer unless the body is very simple. -@node The for Statement +@node The @code{for} Statement @section The @code{for} Statement @cindex @code{for} statement @cindex @code{endfor} statement @@ -548,7 +548,7 @@ more elements to assign. Within Octave is it also possible to iterate over matrices or cell arrays -using the @code{for} statement. For example consider +using the @code{for} statement. For example consider @example @group @@ -565,10 +565,10 @@ @noindent In this case the variable @code{i} takes on the value of the columns of -the matrix or cell matrix. So the first loop iterates twice, producing +the matrix or cell matrix. So the first loop iterates twice, producing two column vectors @code{[1;2]}, followed by @code{[3;4]}, and likewise -for the loop over the cell array. This can be extended to loops over -multidimensional arrays. For example +for the loop over the cell array. This can be extended to loops over +multidimensional arrays. For example @example @group @@ -616,7 +616,7 @@ In this form of the @code{for} statement, the value of @var{expression} must be a structure. If it is, @var{key} and @var{val} are set to the name of the element and the corresponding value in turn, until there are -no more elements. For example, +no more elements. For example, @example @group @@ -650,7 +650,7 @@ structure elements when the names of the elements do not need to be known. -@node The break Statement +@node The @code{break} Statement @section The @code{break} Statement @cindex @code{break} statement @@ -705,7 +705,7 @@ @end group @end example -@node The continue Statement +@node The @code{continue} Statement @section The @code{continue} Statement @cindex @code{continue} statement @@ -754,7 +754,7 @@ @end group @end example -@node The unwind_protect Statement +@node The @code{unwind_protect} Statement @section The @code{unwind_protect} Statement @cindex @code{unwind_protect} statement @cindex @code{unwind_protect_cleanup} @@ -782,7 +782,7 @@ This is useful to protect temporary changes to global variables from possible errors. For example, the following code will always restore -the original value of the global variable @code{frobnositcate} +the original value of the global variable @code{frobnosticate} even if an error occurs in the first part of the @code{unwind_protect} block. @@ -805,7 +805,7 @@ point of the error and the statement to restore the value would not be executed. -@node The try Statement +@node The @code{try} Statement @section The @code{try} Statement @cindex @code{try} statement @cindex @code{catch}