Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 423

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<html lang="en">
<head>
<title>The @code{try} Statement - 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="up" href="Statements.html#Statements" title="Statements">
<link rel="prev" href="The-_0040code_007bunwind_005fprotect_007d-Statement.html#The-_0040code_007bunwind_005fprotect_007d-Statement" title="The @code{unwind_protect} Statement">
<link rel="next" href="Continuation-Lines.html#Continuation-Lines" title="Continuation Lines">
<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="The-%3ccode%3etry%3c%2fcode%3e-Statement"></a>
<a name="The-_003ccode_003etry_003c_002fcode_003e-Statement"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Continuation-Lines.html#Continuation-Lines">Continuation Lines</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="The-_003ccode_003eunwind_005fprotect_003c_002fcode_003e-Statement.html#The-_003ccode_003eunwind_005fprotect_003c_002fcode_003e-Statement">The &lt;code&gt;unwind_protect&lt;/code&gt; Statement</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Statements.html#Statements">Statements</a>
<hr>
</div>

<h3 class="section">10.9 The <code>try</code> Statement</h3>

<p><a name="index-g_t_0040code_007btry_007d-statement-578"></a><a name="index-g_t_0040code_007bcatch_007d-579"></a><a name="index-g_t_0040code_007bend_005ftry_005fcatch_007d-580"></a>
In addition to unwind_protect, Octave supports another limited form of
exception handling.

   <p>The general form of a <code>try</code> block looks like this:

<pre class="example">     try
       <var>body</var>
     catch
       <var>cleanup</var>
     end_try_catch
</pre>
   <p class="noindent">where <var>body</var> and <var>cleanup</var> are both optional and may contain any
Octave expressions or commands.  The statements in <var>cleanup</var> are
only executed if an error occurs in <var>body</var>.

   <p>No warnings or error messages are printed while <var>body</var> is
executing.  If an error does occur during the execution of <var>body</var>,
<var>cleanup</var> can use the function <code>lasterr</code> to access the text
of the message that would have been printed.  This is the same
as <code>eval (</code><var>try</var><code>, </code><var>catch</var><code>)</code> but it is more efficient since
the commands do not need to be parsed each time the <var>try</var> and
<var>catch</var> statements are evaluated.  See <a href="Errors-and-Warnings.html#Errors-and-Warnings">Errors and Warnings</a>, for more
information about the <code>lasterr</code> function.

   <p><a name="index-continuation-lines-581"></a><a name="index-g_t_0040code_007b_002e_002e_002e_007d-continuation-marker-582"></a><a name="index-g_t_0040code_007b_005c_007d-continuation-marker-583"></a>

   </body></html>