3a60dde85f30035be6056eeac7df2ce4cdd6df9f
[scilab.git] / scilab / modules / core / help / en_US / variables / isdef.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2008 - INRIA
5  *
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at
10  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11  *
12  -->
13 <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" xmlns:scilab="http://www.scilab.org" xml:id="isdef" xml:lang="en">
14     <refnamediv>
15         <refname>isdef</refname>
16         <refpurpose>checks variable existence</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>Calling Sequence</title>
20         <synopsis>ve = isdef(name [,where])</synopsis>
21     </refsynopsisdiv>
22     <refsection>
23         <title>Arguments</title>
24         <variablelist>
25             <varlistentry>
26                 <term>ve</term>
27                 <listitem>
28                     <para>
29                         a matrix with the same size as <varname>name</varname> with boolean values
30                     </para>
31                 </listitem>
32             </varlistentry>
33             <varlistentry>
34                 <term>name</term>
35                 <listitem>
36                     <para>a matrix of character strings</para>
37                 </listitem>
38             </varlistentry>
39             <varlistentry>
40                 <term>where</term>
41                 <listitem>
42                     <para>
43                         character string, can be <literal>'l'</literal> (for <literal>"local"</literal>),
44                         <literal>'n'</literal> (for <literal>"nolocal"</literal>) or
45                         <literal>'a'</literal> (for <literal>"all"</literal>). Default value is
46                         <literal>'a'</literal>.
47                     </para>
48                 </listitem>
49             </varlistentry>
50         </variablelist>
51     </refsection>
52     <refsection>
53         <title>Description</title>
54         <para>
55             <code>isdef(name)</code> returns <constant>%T</constant> if the
56             variable named <varname>name</varname> exists and <constant>%F</constant>
57             otherwise.
58         </para>
59         <para>
60             <caution>
61                 Caveats: a function which uses <function>isdef</function> may return a
62                 result which depends on the environment!
63             </caution>
64         </para>
65         <para>
66             <code>isdef(name, 'l')</code> returns <constant>%T</constant>
67             if the variable named <varname>name</varname> exists in the local
68             environment of the current function and <constant>%F</constant>
69             otherwise.
70         </para>
71         <para>
72             <code>isdef(name, 'n')</code> returns
73             <constant>%T</constant> if the variable named <varname>name</varname> exists
74             in the full calling environment (including the global level) of the
75             current function and <constant>%F</constant> otherwise.
76         </para>
77         <note>
78             Note: only the first letter of option <varname>where</varname> is taken into account.
79         </note>
80     </refsection>
81     <refsection>
82         <title>Examples</title>
83         <programlisting role="example"><![CDATA[
84 A = 1; B = 2; C = 3; D = 4;
85 isdef(['A', 'B'; 'C', 'D'])
86 clear A, B, C, D;
87 isdef(['A', 'B'; 'C', 'D'])
88
89 function level1()
90   function level2()
91     disp(isdef(["a", "b"], "a"));
92     disp(isdef(["a", "b"], "l"));
93     disp(isdef(["a", "b"], "n"));
94   endfunction
95   level2()
96 endfunction
97 function go()
98   a = 1;
99   level1()
100 endfunction
101 go()
102  ]]></programlisting>
103     </refsection>
104     <refsection role="see also">
105         <title>See Also</title>
106         <simplelist type="inline">
107             <member>
108                 <link linkend="exists">exists</link>
109             </member>
110             <member>
111                 <link linkend="isglobal">isglobal</link>
112             </member>
113             <member>
114                 <link linkend="whereis">whereis</link>
115             </member>
116             <member>
117                 <link linkend="type">type</link>
118             </member>
119             <member>
120                 <link linkend="typeof">typeof</link>
121             </member>
122             <member>
123                 <link linkend="clear">clear</link>
124             </member>
125         </simplelist>
126     </refsection>
127 </refentry>