Sortir d'un Forall - End Forall ?

Forum destiné aux questions sur le développement : Formules, LotusScript, Java ...

Sortir d'un Forall - End Forall ?

Messagepar lemm » 14 Jan 2004 à 12:43

Salut à tous.J'aimerais sortir d'une boucle :Forall element In doc.listeelement If element = "c'est bon inutile de boucler betement" then ' que faire ??? End IfEnd Forallsi je met un loop until, j'ai plus mon forall...nb : j'ai deux forall imbriqués (j'en n'ai mis qu'un)re-nb : pour éviter les multiples "phil" mon pseudo désormais sera "lemm"(prénom de mon vieux ranger lord 11 de AD&D 1st édition !)
lemm
 

Re: Sortir d'un Forall - End Forall ?

Messagepar Oguruma59 » 14 Jan 2004 à 13:12

tout simplement leExit For et le Exit Do (pour une boucle loop)tiens le doc d'aide si tu en veux plus...Terminates execution of the current block statement.SyntaxExit blockTypeElementsblockTypeA keyword designating the type of the block statement for which execution is to be terminated. It must be one of the following keywords:DoForForAllFunctionSubPropertyUsageWhen LotusScript encounters this statement, it returns control to the scope containing the block statement for which execution is to be terminated.An Exit statement of a particular type is legal only within an enclosing block statement. LotusScript returns control from the innermost block statement or procedure of that type.However, the innermost block statement containing the Exit statement need not be of that type. For example, a function definition can include a For...Next block statement, and an Exit Function statement can appear within this statement. If LotusScript encounters the Exit Function statement during execution, control is returned immediately from the function, in which case the For...Next block statement is not executed to completion.The following table shows the rules for transfer of control after the Exit statement. Exit block type Execution continues Exit Do At the first statement following the end of the Do block statement. Exit For At the first statement following the end of the For block statement. Exit ForAll At the first statement following the end of the ForAll block statement. Exit Function In the calling script, as it would from a normal return from the procedure. Exit Sub In the calling script, as it would from a normal return from the procedure. Exit Property In the calling script, as it would from a normal return from the procedure.
Oguruma59
 

Re: Sortir d'un Forall - End Forall ?

Messagepar PhilippeG » 14 Jan 2004 à 13:12

Bonjourt'as essayé exit forall ?normalement tu reprends l'execution du script à l'instruction suivant le end forall
PhilippeG
 

Re: Sortir d'un Forall - End Forall ?

Messagepar Oguruma59 » 14 Jan 2004 à 13:50

oui j'ai déjà fait...en v4 & v5pkoi tu as eu des soucis.. avec ?
Oguruma59
 

Re: Sortir d'un Forall - End Forall ?

Messagepar Fournery » 14 Jan 2004 à 13:59

BonjourVoici ma techniqueQue ce soit for, while, foralldébut de boucleje fais : if condition then goto AllerHorsDeLaBoucleFin de boucleAllerHorsDeLaBoucle:[%sig%]
Fournery
 

Re: Sortir d'un Forall - End Forall ?

Messagepar Oguruma59 » 14 Jan 2004 à 15:21

là je suis tout à fait d'accord, je suis pas un fou du goto mais quand il est bien placé, il joue le rôle du bouton d'arrêt d'urgence...bon il y a les fanas de prog dite structurée, celle du PERFORM UNTIL en COBOL avec des PERFORM à 4 niveaux pour ne pas faire de GOTO proprement.Ceci, dit il ne faut en abuser et en venir à de la prog "bout de ficelle"par contre pour le While... Wend on n'a pas d'autre méthode que le Gotomais en général les Exit... fonctionnent bien
Oguruma59
 

merci : Sortir d'un Forall - End Forall ?

Messagepar lemm » 14 Jan 2004 à 15:39

Merci. mon blème c'était d'être sûr de sortir des deux forall et du ifl'objet du délit : cest_bon = falseForall maliste In doc1.toutesmeslistes Set doc2 = vue.Getdocumentbykey(Cstr(maliste)) If Not (doc2 is Nothing) Then Forall element In doc2.laliste if cstr(element) = "ok c'est bon" then cest_bon = true Exit Forall ' <-- là je sortirais bien du premier forall et du if End if End Forall Else Print " y'a un blème sur doc2" End if if cest_bon = true then Exit Forall ' <-- et là du deuxième grace à la var <cest_bon> End ifEnd ForallThanks à vous all mais je ne suis plus fan de goto(même en cobol j'avais adopté perform ah...le bon vieux temps...)
lemm
 


Retour vers Développement

cron