Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ON ERROR mystery
Message
De
11/08/2005 18:08:43
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01040132
Message ID:
01040447
Vues:
23
>You are RIGHT Fabio.
>
>I added a button called cmdRUN to form2 and when I call prg1 from form2.cmdrun.click() the ON ERROR triggers and it's OK.
>
>But, I still need to call prg1 from the form2.fire() method (it is supposed to run without any User Interaction).
>
>So, when I put
>
>thisform.cmdRun.click()
>
>in the thisform.fire() method, I still have the same problem!!
>(where ON ERROR does not trigger and instead form2.error() takes priority).
>
>Is there any way I can run prg1 from the form2.fire() method, and have ON ERROR trigger in prg1 ?
>
>Thanks
>

No.
When one or more objects with defined Error() are on the stack,
VFP call the bottom object.Error() defined.

Way of escaping by this rule doesn't exist.

>PS: I looked at TRY..Catch in helpfile as Doug suggested, but since I have never used it, I can't figure out how to substiture a simple
>"ON ERROR DO errhand1" with TRY..CATCH equivalent. It seems a lot more complex and would require massive code change. In each section of prg1, there is a different ON ERROR DO errhand1 in effect where errhand1, errhand2, ... do different things. So, I would much rather get the ON ERROR in prg1 working anyway possible.

TRY..CATCH is not fully compatible with Error() and ON ERROR,
and you have to rewrite all the error handlig of the application.

But for a single procedure with multiple errors handling
you should make a small effort and to use TRY and CATCH.

You can try this, but ERROR() is not set, and TRY..CATCH don't support RETRY, and ....
proc prg1
TRY
 ...
CATCH WHEN condition1
  DO errhand1
CATCH WHEN condition1
  DO errhand2
ENDTRY
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform