Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - Português

Change language to:
English - Français - 日本語 - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Ajuda do Scilab >> Scilab > Control flow > while

while

palavra-chave da estrutura while (significa "enquanto...")

Descrição

while . Deve ser terminado por "end"

while expressão ,instruções1,...[,else instruções], end

while expressão do instruções1,...[,else instruções], end

while expressão then instruções1,...[,else instruções], end

Notas:

  • A única restrição é que cada palavra-chave "then" ou "do" deve estar na mesma linha que a palavra-chave "while".

  • As palavras-chaves "then" ou "do" podem ser substituídas por um retorno de carro ou uma vírgula. Para compatibilidade com o Matlab, também é possível, mas não recomendado, por um espaço entre o fim da expressão e o início da primeira instrução.

  • A construção opcional ,else instruções permite fornecer instruções que são executadas quando a expressão expressão torna-se falsa.

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

  • Start each statement on a new line.

  • Write no more than one simple statement per line.

  • Break compound statements over multiple lines.

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
O número de caracateres usados para definir o corpo de qualquer estrutura condicional (if while for ou select/case) deve ser limitado a 16k.

Exemplos

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

Ver Também

Histórico

VersãoDescrição
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 >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 15:00:33 CET 2019