Hi Michael,

I've tried to upset your code, but am unsuccessfull in recreating the
situation you describe
However, I can take an educated guess on why the case-statement did only
execute the otherwise while you'd expect it would:
VARTYPE(varname, .T.) will return the type that a variable or property
contains. The .T. as a 2nd parameter will cause VARTYPE not to return "X" in
case of a .NULL. value but the type it was previous to setting it to .null.
So if the property boLoadSupplier contained an object but was reset to
.null. the VARTYPE(Thisform.boTradingSheet,.t.) will return "O" and thus
won't execute the branch.
Solution: Just use VARTYPE() without the 2nd parameter. This will only
return "O" when the object is actually there.

Regards,
Sietse Wijnker

 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Michael Hawksworth
> Sent: vrijdag 18 augustus 2006 12:39
> To: [EMAIL PROTECTED]
> Subject: Case Statement
> 
> Could you try running this code and see if the otherwise 
> clause executes?  I forgot to have the form load the 
> boLoadSupplier business object and the routine should have 
> trapped it but it appear to set lcErrorMsg and then run the 
> otherwise code.  If it does work could you try making the 
> first line " Case vartype(llOK,.t.) = 'L' " so that it fails 
> on the second line and see if otherwise executes.
> 
> Thanks
> 
> local lcErrorMsg as string
> lcErrorMsg = ''
> 
> local llOK as Logical
> llOK = .f.
> 
> Do case
>     Case Vartype(thisform.boTradingSheet,.t.)         <> 'O'
>         lcErrorMsg    =    "boTradingSheet"
>     Case Vartype(thisform.boLoadSupplier,.t.)         <> 'O'
>         lcErrorMsg    =    "boLoadSupplier"
>     Case Vartype(thisform.boTradingLoad,.t.)         <> 'O'
>         lcErrorMsg    =    "boTradingLoad"
>     Case Vartype(thisform.boOrganisation,.t.)         <> 'O'
>         lcErrorMsg    =    "boOrganisation"
>     Case Vartype(thisform.boProductCodes,.t.)         <> 'O'
>         lcErrorMsg    =    "boProductCodes"
>     Case Vartype(thisform.boUsers,.t.)                 <> 'O'
>         lcErrorMsg    =    "boUsers"
>     Otherwise
>         If ! Empty(lcErrorMsg)
>             Assert .f. Message 'There IS a bug in foxpro'
>         else
>             llOK = .t.
>         EndIf
> EndCase
> 
> If ! llOK
>     Assert .f. Message 'Unable to load business object '+ 
> Chr(13) + lcErrorMsg
>     Return .f.
> EndIf
> 
> --
> Michael Hawksworth
> Visual Fox Solutions
> 
> [EMAIL PROTECTED]
> www.foxpro.co.uk
> 
> 
> 
> 
> 
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to