Returns the class name of a value.
ClassName := Type(Value)
Type: String
This function returns the class name of Value.
The algorithm for determining a value's class name can be approximated as shown below:
TypeOf(Value) { if (comClass := ComObjType(Value, "Class")) != "" return comClass try ; `Value is Object` is not checked because it can be false for prototypes. if ObjHasOwnProp(Value, "__Class") return "Prototype" while Value := ObjGetBase(Value) if ObjHasOwnProp(Value, "__Class") return Value.__Class return "Object" }
For COM wrapper objects, the class name can also be determined based on the variant type, as follows:
ComObject_Type(obj) { if ComObjType(obj) & 0x2000 ; VT_ARRAY return "ComObjArray" ; ComObjArray.Prototype.__Class if ComObjType(obj) & 0x4000 ; VT_BYREF return "ComValueRef" ; ComValueRef.Prototype.__Class if (ComObjType(obj) = 9 || ComObjType(obj) = 13) ; VT_DISPATCH || VT_UNKNOWN && ComObjValue(obj) != 0 { if (comClass := ComObjType(obj, "Class")) != "" return comClass if ComObjType(obj) = 9 ; VT_DISPATCH return "ComObject" ; ComObject.Prototype.__Class } return "ComValue" ; ComValue.Prototype.__Class }
This function typically shouldn't be used to determine if a value is numeric, since numeric strings are valid in math expressions and with most built-in functions. However, in some cases the exact type of a value is more important. In such cases, consider using Value is Number
or similar instead of Type.
To check if a value can be used as a number, use the IsNumber, IsInteger or IsFloat function.
To check for any type of object (that is, anything which is not a primitive value), use the IsObject function.
To check if a value is an instance of a specific class, use the is
operator. This can be used even with primitive values or to identify COM wrapper objects.
Values, Expressions, Is functions, Integer, Float, String