1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
<?xml version="1.0" encoding="UTF-8"?>
<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" version="5.0-subset Scilab" xml:lang="fr" xml:id="global">
<info>
<pubdate>$LastChangedDate$</pubdate>
</info>
<refnamediv>
<refname>global </refname>
<refpurpose> définition de variables globales </refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Séquence d'appel</title>
<synopsis>global('nam1',...,'namn')
global nam1 ... namn</synopsis>
</refsynopsisdiv>
<refsection>
<title>Paramètres</title>
<variablelist>
<varlistentry>
<term>nam1,..., namn </term>
<listitem>
<para>noms valides de variables
</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>
Habituellement, chaque fonction Scilab a ses propres variables locales et peut accéder "en lecture uniquement" à toutes les variables de l'environnement principal et des fonctions appelantes. Le mot-clé <literal>global</literal> permet de partager certaines variables en lecture/écriture entre des fonctions.
Toute affectation à ces variables est propagée à toutes les autres fonctions ayant déclaré cette variable globale (avec le mot-clé <literal>global</literal>).
</para>
<para>
Si la variable n'existe pas au moment où elle est déclarée globale avec le mot-clé <literal>global</literal>, elle est initialisée avec une matrice vide [].
</para>
</refsection>
<refsection>
<title>Exemples</title>
<programlisting role="example"><![CDATA[
// 1 : l'environnement appelant et une fonction partagent une variable
global a
a=1
deff('y=f1(x)','global a,a=x^2,y=a^2')
f1(2)
a
// 2 : trois fonctions partagent des variables
deff('initdata()','global A C ;A=10,C=30')
deff('letsgo()','global A C ;disp(A) ;C=70')
deff('letsgo1()','global C ;disp(C)')
initdata()
letsgo()
letsgo1()
]]></programlisting>
</refsection>
<refsection>
<title>Voir Aussi</title>
<simplelist type="inline">
<member>
<link linkend="who">who</link>
</member>
<member>
<link linkend="isglobal">isglobal</link>
</member>
<member>
<link linkend="clearglobal">clearglobal</link>
</member>
<member>
<link linkend="gstacksize">gstacksize</link>
</member>
<member>
<link linkend="resume">resume</link>
</member>
</simplelist>
</refsection>
</refentry>
|