Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Try/Catch
Message
De
07/08/2007 14:17:35
 
 
À
07/08/2007 11:23:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01246493
Message ID:
01246561
Vues:
27
I cheat alittle and use TRY/ENDTRY when I want to do something that I am not sure can be done on some systems but don't want it caught in the apps error handler.



>Try/catch is for ERRORS, not for regular conditions. You -may- use the ERROR command to raise fake errors, but that's not what try/catch is meant for. But it fits your purpose, it's yur choice.
>
>>Not sure. I'm going to be testing for a number of conditions, whenever m.MyVariable = .T. then I want to immediately kickout. If this isn't a good application of TRY/CATCH, then what is? I'm just trying to use functionality that's available and this sounded like a good fit.
>>
>>
>>>Why do you need TRY..ENDTRY? It sounds like IF..ENDIF or DO CASE will do.
>>>
>>>>In the TRY block I want to test for certain conditions, if those conditions prove false, then I want to go to the CATCH block and do some other stuff. I think I should use THROW, but I can't figure out how to do it. I'm new to using the TRY/CATCH stuff.
>>>>
>>>>
>>>>TRY
>>>>
>>>>   Bunches of code...
>>>>
>>>>CATCH TO oException (come here if a variable in the TRY block proves false - not sure I even need oException here)
>>>>
>>>>   IF oException.ErrorNo = 1
>>>>      STRTOFILE("Error occurred at: " + TRANSFORM(DATETIME());
>>>>         + CHR(13),"C:\Errors.log",.T.)
>>>>   ENDIF
>>>>
>>>>FINALLY
>>>>
>>>>   RETURN .T.
>>>>
>>>>ENDTRY
>>>>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform