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.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement