AINSTANCE( ) Function 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.

CLEAR ALL
goINSTANCE1 = CREATEOBJECT('Form')
goINSTANCE2 = CREATEOBJECT('Form')

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