~ubuntu-branches/debian/sid/octave3.0/sid

« back to all changes in this revision

Viewing changes to doc/interpreter/HTML/The-try-Statement.html

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2007-12-23 16:04:15 UTC
  • Revision ID: james.westby@ubuntu.com-20071223160415-n4gk468dihy22e9v
Tags: upstream-3.0.0
ImportĀ upstreamĀ versionĀ 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html lang="en">
 
2
<head>
 
3
<title>The try Statement - Untitled</title>
 
4
<meta http-equiv="Content-Type" content="text/html">
 
5
<meta name="description" content="Untitled">
 
6
<meta name="generator" content="makeinfo 4.11">
 
7
<link title="Top" rel="start" href="index.html#Top">
 
8
<link rel="up" href="Statements.html#Statements" title="Statements">
 
9
<link rel="prev" href="The-unwind_005fprotect-Statement.html#The-unwind_005fprotect-Statement" title="The unwind_protect Statement">
 
10
<link rel="next" href="Continuation-Lines.html#Continuation-Lines" title="Continuation Lines">
 
11
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
 
12
<meta http-equiv="Content-Style-Type" content="text/css">
 
13
<style type="text/css"><!--
 
14
  pre.display { font-family:inherit }
 
15
  pre.format  { font-family:inherit }
 
16
  pre.smalldisplay { font-family:inherit; font-size:smaller }
 
17
  pre.smallformat  { font-family:inherit; font-size:smaller }
 
18
  pre.smallexample { font-size:smaller }
 
19
  pre.smalllisp    { font-size:smaller }
 
20
  span.sc    { font-variant:small-caps }
 
21
  span.roman { font-family:serif; font-weight:normal; } 
 
22
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
 
23
--></style>
 
24
</head>
 
25
<body>
 
26
<div class="node">
 
27
<p>
 
28
<a name="The-try-Statement"></a>
 
29
Next:&nbsp;<a rel="next" accesskey="n" href="Continuation-Lines.html#Continuation-Lines">Continuation Lines</a>,
 
30
Previous:&nbsp;<a rel="previous" accesskey="p" href="The-unwind_005fprotect-Statement.html#The-unwind_005fprotect-Statement">The unwind_protect Statement</a>,
 
31
Up:&nbsp;<a rel="up" accesskey="u" href="Statements.html#Statements">Statements</a>
 
32
<hr>
 
33
</div>
 
34
 
 
35
<h3 class="section">10.9 The <code>try</code> Statement</h3>
 
36
 
 
37
<p><a name="index-g_t_0040code_007btry_007d-statement-554"></a><a name="index-g_t_0040code_007bcatch_007d-555"></a><a name="index-g_t_0040code_007bend_005ftry_005fcatch_007d-556"></a>
 
38
In addition to unwind_protect, Octave supports another limited form of
 
39
exception handling.
 
40
 
 
41
   <p>The general form of a <code>try</code> block looks like this:
 
42
 
 
43
<pre class="example">     try
 
44
       <var>body</var>
 
45
     catch
 
46
       <var>cleanup</var>
 
47
     end_try_catch
 
48
</pre>
 
49
   <p class="noindent">where <var>body</var> and <var>cleanup</var> are both optional and may contain any
 
50
Octave expressions or commands.  The statements in <var>cleanup</var> are
 
51
only executed if an error occurs in <var>body</var>.
 
52
 
 
53
   <p>No warnings or error messages are printed while <var>body</var> is
 
54
executing.  If an error does occur during the execution of <var>body</var>,
 
55
<var>cleanup</var> can use the function <code>lasterr</code> to access the text
 
56
of the message that would have been printed.  This is the same
 
57
as <code>eval (</code><var>try</var><code>, </code><var>catch</var><code>)</code> but it is more efficient since
 
58
the commands do not need to be parsed each time the <var>try</var> and
 
59
<var>catch</var> statements are evaluated.  See <a href="Errors-and-Warnings.html#Errors-and-Warnings">Errors and Warnings</a>, for more
 
60
information about the <code>lasterr</code> function.
 
61
 
 
62
   <p><a name="index-continuation-lines-557"></a><a name="index-g_t_0040code_007b_002e_002e_002e_007d-continuation-marker-558"></a><a name="index-g_t_0040code_007b_005c_007d-continuation-marker-559"></a>
 
63
 
 
64
   </body></html>
 
65