53c6a82e790a46a6204db59771602b6b7859fa6b
[scilab.git] / scilab / modules / core / help / en_US / control_flow / resume.xml
1 <?xml version="1.0" encoding="UTF-8"?>
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:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="resume">
3     <refnamediv>
4         <refname>resume</refname>
5         <refpurpose>return or resume execution and copy some local variables</refpurpose>
6     </refnamediv>
7     <refsynopsisdiv>
8         <title>Calling Sequence</title>
9         <synopsis>resume
10             [x1,..,xn]=resume(a1,..,an)
11         </synopsis>
12     </refsynopsisdiv>
13     <refsection>
14         <title>Arguments</title>
15         <variablelist>
16             <varlistentry>
17                 <term>x1,..,xn</term>
18                 <listitem>
19                     <para>variables in calling environment</para>
20                 </listitem>
21             </varlistentry>
22             <varlistentry>
23                 <term>a1,..,an</term>
24                 <listitem>
25                     <para>local variables</para>
26                 </listitem>
27             </varlistentry>
28         </variablelist>
29     </refsection>
30     <refsection>
31         <title>Description</title>
32         <para>
33             In a function <literal>resume</literal> stops the execution of the function,
34             <literal>[x1,..,xn]=resume(a1,..,an)</literal> stops the execution of the function and put the
35             local variables <literal>ai</literal> in calling environment under names
36             <literal>xi</literal>.
37         </para>
38         <para>
39             In <literal>pause</literal> mode, it allows to return to lower level
40             <literal>[x1,..,xn]=resume(a1,..,an)</literal> returns to lower level and put the local variables
41             <literal>ai</literal> in calling environment under names <literal>xi</literal>.
42         </para>
43         <para>
44             In an <literal>execstr</literal> called by a function <literal>[..]=resume(..)</literal> stops
45             the execution of the function and put the local variables 
46             <literal>ai</literal> in calling environment under names <literal>xi</literal>.
47         </para>
48         <para>
49             <literal>resume</literal> is equivalent to <literal>return</literal>.
50         </para>
51         <para>
52             <note>
53                 Note: the usage of this feature can complexify the code. Instead, the syntax <code>function b = foo()</code> is recommended.
54             </note>
55         </para>
56     </refsection>
57     <refsection>
58         <title>Examples</title>
59         <programlisting role="example"><![CDATA[
60 function foo(a)
61          a=a+1
62          b=resume(a)
63          c=52
64 endfunction
65
66 foo(42);
67 assert_checkequal(b,43);
68 // c does not exist
69
70 ]]></programlisting>
71     </refsection>
72     <refsection role="see also">
73         <title>See Also</title>
74         <simplelist type="inline">
75             <member>
76                 <link linkend="abort">abort</link>
77             </member>
78             <member>
79                 <link linkend="break">break</link>
80             </member>
81             <member>
82                 <link linkend="pause">pause</link>
83             </member>
84             <member>
85                 <link linkend="quit">quit</link>
86             </member>
87             <member>
88                 <link linkend="return">return</link>
89             </member>
90             <member>
91                 <link linkend="execstr">execstr</link>
92             </member>
93         </simplelist>
94     </refsection>
95 </refentry>