Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there an 'IsClass()' function?
Message
From
08/11/2003 17:10:42
 
 
To
08/11/2003 16:05:05
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00847972
Message ID:
00847982
Views:
23
Your question is somewhat ill-defined. What is it that you want to achieve? Unless we know that it is impossible to give a good answer.

CREATEOBJECT("CFoo") can fail for any number of reasons, even if instances of the class CFoo do currently exist in memory. You may have failed to supply the correct parameters that the .INIT event of the class expects and thus caused the .INIT to return .F., or Fox may have failed to find the class definition because it is not in the current effective class search path, or Fox may have failed to find the definition for the base class of CFoo for the same reason, or whatever.

One way of avoiding the question IsClass() altogether for PRG-based classes is to put each class in its own .PRG and to have the program body return a newly created instance of the class:

[code]
* CFoo.prg

lparameters uArg1, uArg2
return createobject([CFoo], @m.uArg1, @m.uArg2)

define class CFoo as CBar of CBar.fxp

function init (cMeow, nPurr)
* ...

enddefine[/code]

In user code you just say 'oFoo = CFoo("meow", 666)', without having to fart around with SET PROCEDURE, SET CLASSLIB etc. pp. Works like a charm.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform