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 .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.