\b;Anweisung \c;for\n;
Syntax:
\s;\c;for ( vorher ; bedingung ; ende )
\s;{
\s;	\n;Anweisungen ...\c;
\s;}
\n;
Mit dieser Anweisung können Sie die Anweisungen in dem \l;Block\u cbot\bloc; eine bestimmte Anzahl Male wiederholen.

\t;\c;vorher\n;
This set of instructions is executed before the first loop instance.

\t;\c;bedingung\n;
Diese \l;Bedingung\u cbot\cond; bestimmt, ob die Schleife in weiteres Mal ausgeführt wird. Sie wird jedes Mal getestet, bevor die Schleife ausgeführt wird.

\t;\c;ende\n;
This set of instructions is executed at the end of every instance of the loop. 

Example: count from 1 to 4
\c;\s;\c;for ( i = 1 ; i <= 4 ; i++ )
\s;{
\s;	message(i) ;
\s;}
\n;
Folgendes Beispiel ist einer \c;for\n;-Schleife gleichwertig, benutzt aber die Anweisung \c;\l;while\u cbot\while;\n;:
\s;\c;vorher;
\s;while ( bedingung )
\s;{
\s;	\n;Anweisungen ...\c;
\s;	ende;
\s;}
\n;
\t;Achtung
Am Ende der Zeile mit der \c;for ( )\n;-Anweisung darf kein Strichpunkt stehen.

Die Anweisungen \c;\l;break\u cbot\break;\n; und \c;\l;continue\u cbot\continue;\n; können im Block einer \c;for\n;-Anweisung eingesetzt werden.

\t;Executing more instructions
In the \c;before\n; and \c;end\n; part of a \c;for\n; loop you can specify more than one instruction by using comma. Example:
\c;
\s;int i = 0;
\s;int j;
\s;for (i++, j = 2; i < 3 && j > 0; i++, j--)
\s;{
\s;    message(i);
\s;    message(j);
\s;}
\n;
The output of the above code is \c;1 2 2 1\n;.

\t;Siehe auch
Die \l;CBOT-Sprache\u cbot;, \l;Variablentypen\u cbot\type; und \l;Kategorien\u cbot\category;.

