Lenze DDS v2.3 Manuel d'utilisateur Page 47

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 340
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 46
Drive PLC Developer Studio
Programming languages
4-9
l DDS EN 2.3
4.3.10 WHILE loop
The WHILE loopcanbeusedlikeaFOR loop, the only difference being that the cancel condition can
be any Boolean expression.
Syntax:
WHILE <Boolean expression> DO
<instructions>
END_WHILE;
The <instructions> will be executed again and again until the
<Boolean_expression> returns TRUE.
If <Boolean_expression> is FALSE on first evaluation already, the <instructions> will
never be executed.
If <Boolean_expression> is never FALSE the <instructions> will be repeated
endlessly, forcing a runtime error.
Note!
The programmer himself must ensure that endless loops do not occur by changing the condition
in the instruction part of the loop, for instance change the counter settings. Otherwise the task with
the endless loop would overflow.
Example:
WHILE Counter<>0 DO
Var1:=Var1*2;
Counter:=Counter-1;
END_WHILE
The WHILE and the REPEAT loops are more powerful in a way than the FOR loop since the number
of loop cycles does not need to be known prior to loop execution.
In some cases, these two loop types will have to be sufficient.
If the number of loop cycles is known, however, a FOR loop should be preferred.
Task overflows can also occur in FOR loops.
(^ 4-8)
Show/Hide Bookmarks
Vue de la page 46
1 2 ... 42 43 44 45 46 47 48 49 50 51 52 ... 339 340

Commentaires sur ces manuels

Pas de commentaire