41 lines
1.2 KiB
Plaintext
41 lines
1.2 KiB
Plaintext
\b;Instruction \c;for\n;
|
|
Syntax:
|
|
\s;\c;for ( before ; condition ; end )
|
|
\s;{
|
|
\s; \n;Instructions ...\c;
|
|
\s;}
|
|
\n;
|
|
This instruction allows you to execute a certain number of times the instructions contained in the \l;block\u cbot\bloc;.
|
|
|
|
\t;\c;before\n;
|
|
This instruction is executed before the first loop instance.
|
|
|
|
\t;\c;condition\n;
|
|
This \l;condition\u cbot\cond; determines if another instance of the loop must be executed. It is tested before every instance of the loop.
|
|
|
|
\t;\c;end\n;
|
|
This instruction is executed at the end of every instance of the loop.
|
|
|
|
Example: count from 1 to 4
|
|
\c;\s;\c;for ( i = 0 ; i <= 4 ; i++ )
|
|
\s;{
|
|
\s; message(i) ;
|
|
\s;}
|
|
\n;
|
|
The following example is strictly equivalent to a \c;for\n;-loop, but it uses the instruction \c;\l;while\u cbot\while;\n;:
|
|
\s;\c;before;
|
|
\s;while ( condition )
|
|
\s;{
|
|
\s; \n;Instructions ...\c;
|
|
\s; end;
|
|
\s;}
|
|
\n;
|
|
\t;Attention
|
|
Do not put a \l;semicolon\u cbot\term; at the end of the line \c;for ( )\n;.
|
|
|
|
The instructions \c;\l;break\u cbot\break;\n; and \c;\l;continue\u cbot\continue;\n; can be useful inside a block following the instruction \c;for \n;.
|
|
|
|
\t;See also
|
|
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.
|
|
|