The IsA operator is supposed to be able to evaluate if obj is an instance of the specified class (or of a derivative class).
However, the operator fails to function when invoked by code defined in a different scope.
For example, a utility function named Cast will not work when called from other script libraries:
Function Cast( obj As Variant, ByVal toType As String ) As Variant
Dim retval As Variant
If obj IsA toType Then
Set retval = obj
Else
Error 1037, "Illegal cast: '" & TypeName( obj ) & "' is not a '" & toType & "'"
End If
Set Cast = retval
End Function
If this function is defined in script library B and invoked in script library A (for classes also defined in A), it will always fail.
It seems that IsA can only evaluate classes defined in the same immediate context.
Subject: IsA problem
If the ISa operator does only work under very restricted circumstances, then you should try to use the Typename function.
I have never used IsA. Frankly said, I was not even aware, that his command exists in Lotusscript. Never had any problems with TypeName. Though I have to admit that the IsA function would look more elegant and would be faster to type.
Joe
Subject: IsA works for sub-classes
Using TypeName to compare only lets you determine if an object is an instance of a specific class; IsA also evaluates if the object is an instance of a sub-class of the specified class.
Subject: IsA problem
Yes that’s right, but you can simulate this specific functionality of IsA by creating a list for derived classes that point to their base class or one level up.Well, I know this is ugly compared to a working IsA … but it has the advantage that it works.