>>>>>>I want to know whether a class exists in a certain library before I try to instantiate it in my program (reason: I don't want to get an error message if it doesn't exist). I couldn't find a function for this and the only thing I could come up with is to open the class library programatically and search for objname. This worked, but I felt a little uneasy about touching the .vcx from within a program.
>>>>>>
>>>>>>Can anyone offer any advice, caveats, etc. on this?
>>>>>>
>>>>>>Thanks,
>>>>>>
>>>>>>Sylvia
>>>>>
>>>>>You can put error trap on CREATEOBJECT() line and check for errors without interrupting of program flow.
>>>>
>>>>I already have an error routine in place for the whole program, which under normal circumstances writes errors to a file, then closes down. I thought about temporarily swapping out that routine with another to check for just this error condition, but it started getting into a lot of steps, so I started looking for an alternative.
>>>
>>>Local error trap is very simple:
>>>Local cError,lErrorflag
>>>cError=on("ERROR")
>>>on error lErrorfalg=.t.
>>>oMyobject=createobject("myclass")
>>>on error &cError.
>>>if lErrorfalg=.t.
>>>return 1
>>>else
>>>return 2
>>>endif
>>
>>Ed -
>>
>>I didn't know this could be done. Are you saying that this local error routine will not overwrite my global error routine after I exit from this module? If that's the case, then you're right, this would be better.
>>
>>Sylvia
>
>It will not overwrite. 'cError' preserves it.
Great! Thanks a lot for that tip. I learned something new...that hasn't happened in the past 5 minutes:)
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