* gstacksize removed.
[scilab.git] / scilab / modules / core / help / en_US / 1_keywords / global.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="global">
3     <refnamediv>
4         <refname>global</refname>
5         <refpurpose>Define global variable</refpurpose>
6     </refnamediv>
7     <refsynopsisdiv>
8         <title>Calling Sequence</title>
9         <synopsis>global('nam1',...,'namn')
10             global nam1 ... namn
11         </synopsis>
12     </refsynopsisdiv>
13     <refsection>
14         <title>Arguments</title>
15         <variablelist>
16             <varlistentry>
17                 <term>nam1,..., namn</term>
18                 <listitem>
19                     <para>valid variable names</para>
20                 </listitem>
21             </varlistentry>
22         </variablelist>
23     </refsection>
24     <refsection>
25         <title>Description</title>
26         <para>
27             Ordinarily, each Scilab function, has its
28             own local variables and can "read" all variables created in the base
29             workspace or by the calling functions. The <literal>global</literal> keyword allow to make
30             variables read/write across functions. Any assignment to that variable,
31             in any function, is available to all the other functions declaring
32             it <literal>global</literal>.
33         </para>
34         <para>
35             If the global variable does not exist the first time you issue
36             the <literal>global</literal> statement, it will be initialized to the empty matrix.
37         </para>
38     </refsection>
39     <refsection>
40         <title>Examples</title>
41         <programlisting role="example"><![CDATA[ 
42 //first: calling environnment and a function share a variable
43 global a
44 a=1
45 deff('y=f1(x)','global a,a=x^2,y=a^2')
46 f1(2)
47 a
48 //second: three functions share variables
49 deff('initdata()','global A C ;A=10,C=30')
50 deff('letsgo()','global A C ;disp(A) ;C=70')
51 deff('letsgo1()','global C ;disp(C)')
52 initdata()
53 letsgo()
54 letsgo1()
55  ]]></programlisting>
56     </refsection>
57     <refsection role="see also">
58         <title>See Also</title>
59         <simplelist type="inline">
60             <member>
61                 <link linkend="who">who</link>
62             </member>
63             <member>
64                 <link linkend="isglobal">isglobal</link>
65             </member>
66             <member>
67                 <link linkend="clearglobal">clearglobal</link>
68             </member>
69             <member>
70                 <link linkend="resume">resume</link>
71             </member>
72         </simplelist>
73     </refsection>
74 </refentry>