Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Defensive programming...
Message
De
06/06/2002 09:37:56
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00665394
Message ID:
00665399
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
Hi Chris,

Since you want to check this stuff first thing ( i.e. in Load or BeforeOpenTables ), looks like you might want to do something like add a property to your base form class, something like "CancelFormLoad". Then in your procedures instead of returning a .T./.F. if your requirement fails, you can set the CancelFormLoad property to .T.. Then in the form Init, check this property like
IF THISFORM.CancelFormLoad
    RETURN .F.
ENDIF
Returning .F. from the Init will stop the form from instantiating. You might want to work with this but you get the idea here.

Bill

>Hi - I am trying to understand a bit more about defensive programming! I have this in a procedure...
>
>procedure SetDataEnvironment
>if !file(oApp.SysDataBaseLong) then && return false if file doesn't exist
>	return .f.
>endif
>if !dbused("'" + (oApp.SysDataBaseLong) + "'")
>	open database (oApp.SysDataBaseLong) shared
>	set database to (oApp.SysDataBaseShort)
>	set date british
>	set exclusive off
>	set multilocks on
>	set exact on
>	return .t.
>endif
>endproc
>
>
>I call this in the load of every form just before I open views etc - if the call fails I want to cancel the load of the form and ask the user if they want to try again but I can't seem to cancel out of the load - it seems to run it's course regardless! Any ideas?
>
>Also any general pointers in the area of checking for lost connections to data etc? ie. Lost network connection. What is considered normal practice?
>
>Many thanks
>
>Chris
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform