File: execstr.xml

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (131 lines) | stat: -rw-r--r-- 4,456 bytes parent folder | download
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) XXXX-2008 - INRIA
 * 
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at    
 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 *
 -->
<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="en" xml:id="execstr">
  <info>
    <pubdate>$LastChangedDate$</pubdate>
  </info>
  <refnamediv>
    <refname>execstr</refname>
    <refpurpose> execute Scilab code in strings</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <title>Calling Sequence</title>
    <synopsis>execstr(instr)
ierr=execstr(instr,'errcatch' [,msg])</synopsis>
  </refsynopsisdiv>
  <refsection>
    <title>Parameters</title>
    <variablelist>
      <varlistentry>
        <term>instr</term>
        <listitem>
          <para>vector of character strings, Scilab instruction to be executed.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>ierr</term>
        <listitem>
          <para>integer, 0 or error number.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>msg</term>
        <listitem>
          <para>character string with values <literal>'m'</literal> or <literal>'n'</literal>.  Default value is <literal>'n'</literal>.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsection>
  <refsection>
    <title>Description</title>
    <para>Executes the Scilab instructions given in argument
      <literal>instr</literal>.</para>
    <para>Note that instr should not make use of continuation marks (..) </para>
    <para> </para>
    <para>If the 'errcatch' flag is not present, error handling works as usual.</para>
    <para>If the 'errcatch' flag is set, and an error is encountered while
      executing the instructions defined in <literal>instr</literal>, <literal>execstr</literal>
      issues no error message, but aborts execution of the <literal>instr</literal>
      instructions (at the point where the error occurred), and resumes with
      <literal>ierr</literal> equal to the error number.  In this case the display of the
      error message is controlled by the <literal>msg</literal> option:</para>
    <variablelist>
      <varlistentry>
        <term>"m"</term>
        <listitem>
          <para>error message is displayed and recorded.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>"n"</term>
        <listitem>
          <para>no error message is displayed, but the error message is recorded (see <literal>lasterror</literal>).  This is the default.</para>
        </listitem>
      </varlistentry>
    </variablelist>
    <para> ierr=execstr(instr,'errcatch') can handle syntactical errors. This is
      useful for evalution of instruction obtained by a query to the user.</para>
  </refsection>
  <refsection>
    <title>Examples</title>
    <programlisting role="example"><![CDATA[ 
execstr('a=1') // sets a=1.
execstr('1+1') // does nothing (while evstr('1+1') returns 2)

execstr(['if %t then';
         '  a=1';
         '  b=a+1';
         'else'
         ' b=0'
         'end'])

execstr('a=zzzzzzz','errcatch')
execstr('a=zzzzzzz','errcatch','m')

//syntax errors
execstr('a=1?02','errcatch')
lasterror(%t)

execstr('a=[1 2 3)','errcatch')
lasterror(%t)

// variable1 does not exist
if execstr('variable1;','errcatch')<>0 then disp("Trigger an error"),end

// variable2 exists ... no error is triggered by execstr
variable2=[2,3]; 
if execstr('variable2;','errcatch')<>0 then 
   disp("Trigger an error");
else
   disp("execstr is happy");
end
 ]]></programlisting>
  </refsection>
  <refsection>
    <title>See Also</title>
    <simplelist type="inline">
      <member>
        <link linkend="evstr">evstr</link>
      </member>
      <member>
        <link linkend="lasterror">lasterror</link>
      </member>
      <member>
        <link linkend="error">error</link>
      </member>
      <member>
        <link linkend="try">try</link>
      </member>
    </simplelist>
  </refsection>
</refentry>