Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exiting
Message
De
25/07/2001 17:19:24
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
 
 
À
25/07/2001 13:44:40
Peter Brama
West Pointe Enterprises
Detroit, Michigan, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Divers
Thread ID:
00535201
Message ID:
00535391
Vues:
16
Peter-

Variation on Evan's suggestion...

Sometimes you want to stop checking once any condition is false (or true, as the case may be). The case statement will do that. Sometimes you have to take some action depending on the condition, in which case your nested IFs would be correct. Sometimes you want to know all the things that are wrong, so you might want to check all conditions. In which case, I do something like the following:
LOCAL llFieldOK, llFileExists, llProcessedOK
llFieldOK     = {SomeCondition1}
llFileExists  = {SomeCondition2}
llProcessedOK = {SomeCondition3}

IF !llFieldOK
  *!* Maybe tell the user, or set a flag for an error report.
ENDI

IF !llFileExists  
  *!* Maybe tell the user, or set a flag for an error report.
ENDIF

IF !llProcessedOK 
  *!* Maybe tell the user, or set a flag for an error report.
ENDIF

RETURN llFieldOK .AND. llFileExists .AND. llProcessedOK
>I am writing a procedure that requires a certain set of criteria to happen before the end of the code can process. I need to know, other than a huge set of nested IF ENDIF calls, is there away to jump out of the code.
>
>Here is an example.
>
>In the CLICK method for a button that is labeled NEXT... when the user clicks on the NEXT button, it needs to process some information. If any of it fails it needs to remain on the current form after displaying an error msg. Writing this with IF's would look something like this.
>
>IF - verify proper field data is ok
> ** data OK
> IF - verify file exists
> ** file exists
> IF - processed info created
> ** processed complete
> IF - remaining criteria met
> ** all done
> ** thisform.release
> ELSE
> ** display error
> ENDIF
> ELSE
> ** display error
> ENDIF
> ELSE
> ** display error
> ENDIF
>ELSE
> ** display error
>ENDIF
>
>
>This is true structured programming because it doesn't release the form until all the criteria is met.... BUT... and I know this is wrong for true programmers... but for a large chunk of code, it's easy to lose track of which loop you are in and what needs to happen. I was wondering if there was something like an EXIT call that get you out of the button code and return to the form input.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform