<< try Control flow Configuration >>

Scilab Help >> Scilab > Control flow > while

while

Opens a block of instructions iterated on a heading condition

Description

The while clause must be terminated by "end".

while expr ,instructions,..., end

while expr do instructions,..., end

while expr then instructions,..., end

Notes:

According to the Code Conventions for the Scilab Programming Language it is recommended:

For example, use:

i = 0;
while i<5
    disp(i);
    i = i + 1;
end

rather than

i = 0; while i<5, disp(i), i = i + 1; end
The number of characters used to define the body of any conditional instruction (if while for or select/case) must be limited to 16k.

Examples

e=1; a=1; k=1;
while norm(a-(a+e),1) > %eps,
    e=e/2;
    k=k+1;
end
e,k

See also

History

VersionDescription
6.0.0
  • The [,else instructions] syntax is no longer supported.
  • while is now protected: Assignments like while=1 are no longer possible.

Report an issue
<< try Control flow Configuration >>