Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Please explain 'DO WHILE .T.'
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00307982
Message ID:
00308042
Vues:
22
Neil,

DO WHILE .T. is logically teh same as;

DO UNTIL I TELL YOU TO STOP

.T. is true and it will always be true. The DO WHILE .T. loop will opnly end if the developer uses the EXIT command to exit the loop. The reason Hacker's Guide calls it a bad idea is this;

Invariably there is some cod eiside that loop that is evaluating a condition to see if the loop shoudl end. It is cleaner and clearer to put that expression on the DO WHILE line instead of burried somewher inside the loop.
DO WHILE .T.
   Blah
   Blah
   Blah
   IF NOT Whatever
      EXIT
   ENDIF
   Blah
   Blah
ENDDO
Is better written as;
DO WHILE Whatever
   Blah
   Blah
   Blah
   IF NOT Whatever
      LOOP
   ENDIF
   Blah
   Blah
ENDDO
For the reason why the latter is better, think about caused you to write this question. If the logical control of the loop was oin teh DO WHILE line would you have needed to ask about it, or would you havve understood it right away?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform