25565f6aba364f751b94df3e09a7edb4c7a87a81
[scilab.git] / scilab / modules / string / help / en_US / evstr.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  *
5  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13  *
14  -->
15 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
16         xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
17         xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
18         xmlns:scilab="http://www.scilab.org" xml:id="evstr" xml:lang="en">
19     <refnamediv>
20         <refname>evstr</refname>
21         <refpurpose>evaluation of expressions</refpurpose>
22     </refnamediv>
23     <refsynopsisdiv>
24         <title>Syntax</title>
25         <synopsis>
26             H = evstr(Z)
27             [H, ierr] = evstr(Z)
28         </synopsis>
29     </refsynopsisdiv>
30     <refsection>
31         <title>Arguments</title>
32         <variablelist>
33             <varlistentry>
34                 <term>Z</term>
35                 <listitem>
36                     <para>
37                         a matrix of character strings <varname>M</varname> or
38                         <code>list(M,Subexp)</code>
39                     </para>
40                     <variablelist>
41                         <varlistentry>
42                             <term>M</term>
43                             <listitem>
44                                 <para>a matrix of character strings.</para>
45                             </listitem>
46                         </varlistentry>
47                         <varlistentry>
48                             <term>Subexp</term>
49                             <listitem>
50                                 <para>a vector of character strings.</para>
51                             </listitem>
52                         </varlistentry>
53                     </variablelist>
54                 </listitem>
55             </varlistentry>
56             <varlistentry>
57                 <term>H</term>
58                 <listitem>
59                     <para>a matrix.</para>
60                 </listitem>
61             </varlistentry>
62             <varlistentry>
63                 <term>ierr</term>
64                 <listitem>
65                     <para>an integer, error indicator.</para>
66                 </listitem>
67             </varlistentry>
68         </variablelist>
69     </refsection>
70     <refsection>
71         <title>Description</title>
72         <para>
73             Returns the result of the evaluation of the matrix of character
74             strings <varname>M</varname>. Each element of the matrix must define a
75             valid Scilab expression.
76         </para>
77         <para>
78             If the evaluation of <varname>M</varname> expression leads to an
79             error, the single return value version, <code>H = evstr(M)</code>,
80             raises the error as usual. The two return values version,
81             <code>[H,ierr] = evstr(M)</code>, on the other hand, produces no
82             error, but returns the error number in <varname>ierr</varname>.
83         </para>
84         <para>
85             If <varname>Z</varname> is a list, <varname>Subexp</varname> is a
86             vector of character strings, that defines subexpressions which are
87             evaluated before evaluating <varname>M</varname>. These subexpressions
88             must be referred to as <literal>%(k)</literal> in <varname>M</varname>,
89             where <literal>k</literal> is the subexpression's index in
90             <varname>Subexp</varname>.
91         </para>
92         <para>
93             <code>evstr('a = 1')</code> is not valid (use <function>execstr</function>
94             instead).
95         </para>
96         <para>
97             <literal>Nan</literal>, <literal>NaN</literal> will be interpreted as <constant>%nan</constant>.
98         </para>
99         <para>
100             <literal>Inf</literal> will be interpreted as <constant>%inf</constant>.
101         </para>
102         <warning>
103             <varname>Z</varname> should not include any continuation marks (..).
104         </warning>
105     </refsection>
106     <refsection>
107         <title>Examples</title>
108         <programlisting role="example"><![CDATA[
109 a = 1; b = 2;
110 Z = ['a', 'b'] ;
111 evstr(Z)
112
113 Z = list(['%(1)','%(1)-%(2)'],['a+1','b+1']);
114 evstr(Z)
115
116 evstr('NaN'), evstr('Inf')
117
118 //The two return values version
119 [H, ierr] = evstr(Z) // no error
120 Z = ['a', 'b', 'c'] ;// the variable c is undefined
121 [H, ierr] = evstr(Z) // error 4: Undefined variable: c
122 ]]>    </programlisting>
123     </refsection>
124     <refsection role="see also">
125         <title>See also</title>
126         <simplelist type="inline">
127             <member>
128                 <link linkend="execstr">execstr</link>
129             </member>
130         </simplelist>
131     </refsection>
132 </refentry>