Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coding Standards
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00115272
Message ID:
00116089
Vues:
22
>>I'm not sure I agree with you on use of EXIT...I think the EXIT is a clearer indication of a loop egress than altering an index, so makes for better code readability. I do agree, though, that if you're going to use it, it should go at the end of the code just prior to ENDFOR...
>
>The fact is that almost any code gets modified sooner or later and the "EXIT just prior to ENDFOR" is not a rule enforced by VFP and not all programmers know my rules, etc. This is why I prefer to not do it. But I agree that is clearer than forcing the index. Still, I prefer the code less risky.
>
>Vlad

Since I'm the "culprit" (by starting the discussion of premature loop exits)in this particular end of the thread, I can't help adding the following. Now while I haven't tested this, I would think that the following holds true. Please remember, however, that it is Friday and I seem to have a particular penchant on this day of the week for sticking my size 11s firmly in my mouth.

I don't think that the difference between FOR...ENDFOR and DO WHILE...ENDDO is quite as great as it might first appear in situations where there is an evaluation made to determine whether or not to jump out of the loop. If this is the condition of the DO WHILE statement, this is automatically evaluated there, but has to be inserted as an additional code block in a FOR...ENDFOR. So actually, you may only have one condition being evaluated in a DO WHILE, but two in a FOR (the index counter and the logical evaluation).

One last note. One thing that you'll never see in my stuff is something like the following:
DO WHILE .T.
  * Code here setting
  * Some logical condition
  IF SomeLogicalCondition
    EXIT
  ENDIF
ENDDO
I won't say what I think of the above. I handle these situations with:
lldone = .F.
DO WHILE NOT lldone  
  * Code here setting
  * Some logical condition
  * such as:
  lldone = (this = that)
ENDDO
I think that it's far more readability, and *may* execute faster.

And yeah, I don't use ! to indicate logical NOT.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform