1
1
<?xml version="1.0" encoding="UTF-8"?>
2
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" version="5.0-subset Scilab" xml:lang="en" xml:id="while">
4
<refname>while</refname>
5
<refpurpose> while keyword</refpurpose>
8
<title>Description</title>
10
The <literal>while</literal> clause must be terminated by
11
<literal>"end"</literal>.
14
<literal>while expr ,instructions,...[,else instructions], end</literal>
17
<literal>while expr do instructions,...[,else instructions], end</literal>
20
<literal>while expr then instructions,...[,else instructions], end</literal>
26
The only constraint is that each <literal>then</literal> or
27
<literal>do</literal> keyword must be on the same line line as
28
<literal>while</literal> keyword.
33
Keywords <literal>then</literal> or <literal>do</literal> can
34
be replaced by a carriage return or a comma. For compatibility
35
with Matlab it is also possible, but not recommended, to put a
36
space between the end of the expression and the beginning of
37
the first instruction.
42
The optional <literal>,else instructions</literal> construction
43
allows to gives <literal>instructions</literal> which are executed when
44
<literal>expr</literal> expression becomes false.
49
According to the Code Conventions for the Scilab Programming Language it is recommended:
54
Start each statement on a new line.
59
Write no more than one simple statement per line.
64
Break compound statements over multiple lines.
71
<programlisting role=""><![CDATA[
4
<refname>while</refname>
5
<refpurpose> while keyword</refpurpose>
8
<title>Description</title>
10
The <literal>while</literal> clause must be terminated by
11
<literal>"end"</literal>.
14
<literal>while expr ,instructions,...[,else instructions], end</literal>
17
<literal>while expr do instructions,...[,else instructions], end</literal>
20
<literal>while expr then instructions,...[,else instructions], end</literal>
26
The only constraint is that each <literal>then</literal> or
27
<literal>do</literal> keyword must be on the same line line as
28
<literal>while</literal> keyword.
33
Keywords <literal>then</literal> or <literal>do</literal> can
34
be replaced by a carriage return or a comma. For compatibility
35
with Matlab it is also possible, but not recommended, to put a
36
space between the end of the expression and the beginning of
37
the first instruction.
42
The optional <literal>,else instructions</literal> construction
43
allows to gives <literal>instructions</literal> which are executed when
44
<literal>expr</literal> expression becomes false.
49
According to the Code Conventions for the Scilab Programming Language it is recommended:
54
Start each statement on a new line.
59
Write no more than one simple statement per line.
64
Break compound statements over multiple lines.
71
<programlisting role=""><![CDATA[
77
77
]]></programlisting>
81
<programlisting role=""><![CDATA[
81
<programlisting role=""><![CDATA[
82
82
i = 0; while i<5 disp("i"); i = i + 1; end
83
83
]]></programlisting>
85
Warning: the number of characters used to define the body of any
86
conditionnal instruction (if while for or select/case) must be
91
<title>Examples</title>
92
<programlisting role="example"><![CDATA[
85
Warning: the number of characters used to define the body of any
86
conditionnal instruction (if while for or select/case) must be
91
<title>Examples</title>
92
<programlisting role="example"><![CDATA[
94
94
while norm(a-(a+e),1) > %eps,
99
99
]]></programlisting>
101
<refsection role="see also">
102
<title>See Also</title>
103
<simplelist type="inline">
105
<link linkend="for">for</link>
108
<link linkend="select">select</link>
111
<link linkend="break">break</link>
114
<link linkend="return">return</link>
117
<link linkend="pause">pause</link>
101
<refsection role="see also">
102
<title>See Also</title>
103
<simplelist type="inline">
105
<link linkend="for">for</link>
108
<link linkend="select">select</link>
111
<link linkend="break">break</link>
114
<link linkend="return">return</link>
117
<link linkend="pause">pause</link>