Creates an object from a class definition or an Automation-enabled application.
Syntax
CREATEOBJECT(ClassName [, eParameter1, eParameter2, ...])
Returns
Object
Arguments
ClassName
Specifies the class or OLE object from which the new object is created. Visual FoxPro searches for the class or OLE object in the following order:
OLE objects are created using the following syntax for ClassName:
ApplicationName.Class
For example, to create a Microsoft Excel worksheet (which supports Automation), you can use the following syntax:
x = CREATEOBJECT('Excel.Sheet')
When this code is run, Microsoft Excel is started (if not already running), and a new worksheet is created.
A class library can have an alias. To specify an object in a class library with an alias, include the class library alias followed by a period and the object name.
Note that ClassName cannot be the Visual FoxPro OLE Container control base class.
eParameter1, eParameter2, ...
These optional parameters are used to pass values to the Init event procedure for the class. The Init event is executed when you issue CREATEOBJECT( ) and allows you to initialize the object.
Remarks
Use CREATEOBJECT( ) to create an object from a class definition or an application that supports Automation, and assign a reference to the object to a system variable or array element.
Before you can create an object from a user-defined class, the user-defined class must first be created with DEFINE CLASS, or it must be available in a .vcx visual class library opened with SET CLASSLIB.
Use = or STORE to assign a reference to the object to a system variable or array element. If an object assigned to a system variable or array element is released, the system variable or array element contains the null value. Use RELEASE to remove the system variable or array element from memory.