~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/core/help/en_US/keywords/try.xml

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?xml version="1.0" encoding="UTF-8"?>
2
2
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:id="try" xml:lang="en">
3
 
  <refnamediv>
4
 
    <refname>try</refname>
5
 
    <refpurpose>beginning of try block in try-catch control
6
 
      instruction
7
 
    </refpurpose>
8
 
  </refnamediv>
9
 
  <refnamediv xml:id="catch">
10
 
    <refname>catch</refname>
11
 
    <refpurpose>beginning of catch block in try-catch control
12
 
      instruction
13
 
    </refpurpose>
14
 
  </refnamediv>
15
 
  <refsynopsisdiv>
16
 
    <title>Calling Sequence</title>
17
 
    <synopsis>
18
 
      try
19
 
      statements
20
 
      catch
21
 
      statements
22
 
      end
23
 
    </synopsis>
24
 
  </refsynopsisdiv>
25
 
  <refsection>
26
 
    <title>Description</title>
27
 
    <para>
28
 
      The <literal>try</literal>-<literal>catch</literal> control
29
 
      instruction can be used to manage codes that could possibly generate
30
 
      errors.
31
 
    </para>
32
 
    <para>
33
 
      When a <literal>try</literal>-<literal>catch</literal> control
34
 
      instruction is executed, normally only the statements between the
35
 
      <literal>try</literal> and <literal>catch</literal> keywords are executed.
36
 
      However, if an error occurs during execution of any of these statements,
37
 
      the error is recorded, the remaining statements up to the
38
 
      <literal>catch</literal> keyword are skipped and the statements between
39
 
      the <literal>catch</literal> and <literal>end</literal> keywords are
40
 
      executed using the default error handling mode (see <link linkend="errcatch">errcatch</link>).
41
 
    </para>
42
 
    <para>
43
 
      The recorded error can be retrieved using the <link linkend="lasterror">lasterror</link> function.
44
 
    </para>
45
 
    <para>
46
 
      The <literal>catch</literal> statements as well as the
47
 
      <literal>catch</literal> keyword can be omitted if no alternative
48
 
      statements are given.
49
 
    </para>
50
 
    <para>
51
 
      Note that one can also use the <link linkend="execstr">execstr</link> function with
52
 
      <literal>'errcatch'</literal> argument for error handling. This can be
53
 
      particularly useful for handling syntactical errors.
54
 
    </para>
55
 
    <para>
56
 
      Note also that <literal>try-catch</literal> is more or less similar
57
 
      to:
58
 
    </para>
59
 
    <programlisting role=""><![CDATA[ 
 
3
    <refnamediv>
 
4
        <refname>try</refname>
 
5
        <refpurpose>beginning of try block in try-catch control
 
6
            instruction
 
7
        </refpurpose>
 
8
    </refnamediv>
 
9
    <refnamediv xml:id="catch">
 
10
        <refname>catch</refname>
 
11
        <refpurpose>beginning of catch block in try-catch control
 
12
            instruction
 
13
        </refpurpose>
 
14
    </refnamediv>
 
15
    <refsynopsisdiv>
 
16
        <title>Calling Sequence</title>
 
17
        <synopsis>
 
18
            try
 
19
            statements
 
20
            catch
 
21
            statements
 
22
            end
 
23
        </synopsis>
 
24
    </refsynopsisdiv>
 
25
    <refsection>
 
26
        <title>Description</title>
 
27
        <para>
 
28
            The <literal>try</literal>-<literal>catch</literal> control
 
29
            instruction can be used to manage codes that could possibly generate
 
30
            errors.
 
31
        </para>
 
32
        <para>
 
33
            When a <literal>try</literal>-<literal>catch</literal> control
 
34
            instruction is executed, normally only the statements between the
 
35
            <literal>try</literal> and <literal>catch</literal> keywords are executed.
 
36
            However, if an error occurs during execution of any of these statements,
 
37
            the error is recorded, the remaining statements up to the
 
38
            <literal>catch</literal> keyword are skipped and the statements between
 
39
            the <literal>catch</literal> and <literal>end</literal> keywords are
 
40
            executed using the default error handling mode (see <link linkend="errcatch">errcatch</link>).
 
41
        </para>
 
42
        <para>
 
43
            The recorded error can be retrieved using the <link linkend="lasterror">lasterror</link> function.
 
44
        </para>
 
45
        <para>
 
46
            The <literal>catch</literal> statements as well as the
 
47
            <literal>catch</literal> keyword can be omitted if no alternative
 
48
            statements are given.
 
49
        </para>
 
50
        <para>
 
51
            Note that one can also use the <link linkend="execstr">execstr</link> function with
 
52
            <literal>'errcatch'</literal> argument for error handling. This can be
 
53
            particularly useful for handling syntactical errors.
 
54
        </para>
 
55
        <para>
 
56
            Note also that <literal>try-catch</literal> is more or less similar
 
57
            to:
 
58
        </para>
 
59
        <programlisting role=""><![CDATA[ 
60
60
if execstr("<try instructions>","errcatch")<>0 then
61
61
  <catch instructions>
62
62
end
63
63
 ]]></programlisting>
64
 
    <para>
65
 
      It uses the same internal mechanism as <link linkend="errcatch">errcatch</link>. It is the reason why <link linkend="errcatch">errcatch</link> or
66
 
      <emphasis>execstr(...,"errcatch")</emphasis> cannot be included in
67
 
      <literal>try</literal>-<literal>catch</literal> control structures. This
68
 
      context is detected and produces a specific error message (this error is
69
 
      caught and stored like any other error if it is triggered in the
70
 
      <literal>try</literal> block).
71
 
    </para>
72
 
    <para>
73
 
      However, <literal>try</literal>-<literal>catch</literal> control
74
 
      structures can be nested (see example 2 below).
75
 
    </para>
76
 
  </refsection>
77
 
  <refsection>
78
 
    <title>Examples</title>
79
 
    <programlisting role="example"><![CDATA[ 
 
64
        <para>
 
65
            It uses the same internal mechanism as <link linkend="errcatch">errcatch</link>. It is the reason why <link linkend="errcatch">errcatch</link> or
 
66
            <emphasis>execstr(...,"errcatch")</emphasis> cannot be included in
 
67
            <literal>try</literal>-<literal>catch</literal> control structures. This
 
68
            context is detected and produces a specific error message (this error is
 
69
            caught and stored like any other error if it is triggered in the
 
70
            <literal>try</literal> block).
 
71
        </para>
 
72
        <para>
 
73
            However, <literal>try</literal>-<literal>catch</literal> control
 
74
            structures can be nested (see example 2 below).
 
75
        </para>
 
76
    </refsection>
 
77
    <refsection>
 
78
        <title>Examples</title>
 
79
        <programlisting role="example"><![CDATA[ 
80
80
// example 1
81
81
file_path=TMPDIR+'/wrong'
82
82
try
88
88
end 
89
89
 [error_message,error_number]=lasterror(%t)
90
90
 ]]></programlisting>
91
 
    <programlisting role="example"><![CDATA[ 
 
91
        <programlisting role="example"><![CDATA[ 
92
92
// example 2 (nested try/catch structures)
93
93
function nestedtry(a,b)
94
94
disp("START")
113
113
nestedtry(1,"a string")
114
114
nestedtry("a string","a string")
115
115
 ]]></programlisting>
116
 
  </refsection>
117
 
  <refsection role="see also">
118
 
    <title>See Also</title>
119
 
    <simplelist type="inline">
120
 
      <member>
121
 
        <link linkend="error">error</link>
122
 
      </member>
123
 
      <member>
124
 
        <link linkend="execstr">execstr</link>
125
 
      </member>
126
 
      <member>
127
 
        <link linkend="if">if</link>
128
 
      </member>
129
 
      <member>
130
 
        <link linkend="lasterror">lasterror</link>
131
 
      </member>
132
 
      <member>
133
 
        <link linkend="errcatch">errcatch</link>
134
 
      </member>
135
 
    </simplelist>
136
 
  </refsection>
 
116
    </refsection>
 
117
    <refsection role="see also">
 
118
        <title>See Also</title>
 
119
        <simplelist type="inline">
 
120
            <member>
 
121
                <link linkend="error">error</link>
 
122
            </member>
 
123
            <member>
 
124
                <link linkend="execstr">execstr</link>
 
125
            </member>
 
126
            <member>
 
127
                <link linkend="if">if</link>
 
128
            </member>
 
129
            <member>
 
130
                <link linkend="lasterror">lasterror</link>
 
131
            </member>
 
132
            <member>
 
133
                <link linkend="errcatch">errcatch</link>
 
134
            </member>
 
135
        </simplelist>
 
136
    </refsection>
137
137
</refentry>