JavaScript Editor js editor     Web development 



Main Page

Places instances of a class into a variable array and returns the number of instances placed in the array.

AINSTANCE(ArrayName, cClassName)

Parameters

ArrayName


Specifies the name of the array into which the instances are placed. If the array you specify doesn't exist, Visual FoxPro automatically creates the array. If the array exists and isn't large enough to contain all the instances, Visual FoxPro automatically increases the size of the array to accommodate the instances. If the array is larger than necessary, Visual FoxPro truncates the array. If the array exists and AINSTANCE(В ) returns 0 because no instances are found, the array remains unchanged. If the array doesn't exist and AINSTANCE(В ) returns 0, the array is not created. Only class instances assigned to variables and array elements with CREATEOBJECT(В ) or NEWOBJECT(В ) are placed into the array.
cClassName


Specifies a Visual FoxPro base class name or a user-defined class name. For a complete list of the Visual FoxPro base classes, see Base Classes in Visual FoxPro.

Return Value

Numeric

Example

In the following example, CREATEOBJECT(В ) is used to create two instances of the Visual FoxPro Form base class. AINSTANCE(В ) is used to create an array named gaMyArray that contains the variable references (goINSTANCE1 and goINSTANCE2) for each form instance. The contents of the array are then displayed.

В Copy Code
CLEAR ALL
goINSTANCE1 = CREATEOBJECT('Form')
goINSTANCE2 = CREATEOBJECT('Form')

CLEAR
? AINSTANCE(gaMyArray, 'Form')  && Returns 2, two form instances 
DISPLAY MEMORY LIKE gaMyArray  && Displays the references

See Also



JavaScript Editor js editor     Web development