Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

AClass()

AClass() lets you take an object and find out its entire lineage. An object is based on a class. That class may be a sub-class of another class, which may be a sub-class of another, and so on and so forth. AClass() stuffs the entire class hierarchy for the object into an array.

Usage

nLevels = ACLASS( ArrayName, oObject )

Parameter

Value

Meaning

ArrayName

Name

Array to hold class hierarchy for oObject.

oObject

Object

The object for which to trace the class hierarchy.

nLevels

Positive number

The number of rows in the array, which is the number of levels in the class hierarchy.

0

ArrayName can't be created.

The class on which oObject is based goes in the first array element. That class’ parent class goes in the second element and so forth. The last array element holds the name of the Visual FoxPro base class on which the entire hierarchy is based.

Because the function gives an error if oObject isn’t an object or you pass too many or too few parameters, we haven’t been able to find a case where AClass() returns 0. Nonetheless, it’s good to know that the FoxPro development team has coded for all the oddball situations.

Example

oForm = CREATEOBJECT("Form") && create a new form
= AClass(aFormHier, oForm)   && creates a one-element array
                             && containing "FORM"

SET CLASSLIB TO HOME() + "WIZARDS\WIZSTYLE" && wizard classes
oBoxFld = CREATEOBJECT("BoxField")
= AClass(aBoxHier, oBoxFld) && creates a three- element array,
                            && with "BOXFIELD" in 1st element,
                            && "BOXBASE in 2nd
                            && and "CONTAINER" in 3rd.

See Also

AInstance(), AMembers(), Array Manipulation, CreateObject(), Define Class