Creates a new class or object directly from a visual class library (.vcx) file or program (.prg) file without opening the file.
NEWOBJECT(cClassName [, cModule [, cInApplication | 0 [, eParameter1, eParameter2, ...]]])
- Specifies the class or object from which the new class or object is created.
Specifies a .vcx file or Visual FoxPro program (.prg, .fxp, .mpr, .app, .exe, and so on) containing the class or object specified with cClassName. The default is a .vcx file. If you specify a program file, you must include an extension.
When possible, specify the compiled program name (.fxp) when a class is stored in a program file (.prg). This ensures that the class is loaded from the proper class definition file. If cModule is omitted, or is the empty string or the null value, Visual FoxPro searches for the class or object in the following order:
Note: A class library can have an alias. To specify a class or object from a class library with an alias, include the class library alias followed by a period and the object name.
Visual FoxPro base classes.
Classes in the current program.
Class libraries opened with SET CLASSLIB.
Classes in procedure files opened with SET PROCEDURE.
Classes in the Visual FoxPro program execution chain.
The OLE registry if SET OLEOBJECT is ON.
- Visual FoxPro base classes.
- Specifies the Visual FoxPro application (.exe or .app) containing the .vcx file you specify with cModule. You must include an extension for the application. CInApplication is ignored if cModule is omitted, or if cInApplication is the empty string or the null value. If you want to use the cInApplication parameter, you must specify the name of .vcx file for cModule. You cannot pass the name of a .prg file or compiled program (.fxp).
- Specifies that the class or object is instantiated without executing any of the event or method code in the class or object. This feature is not supported in runtime applications. All child classes or objects of the parent class are also instantiated. The event or method code in the child class or object isn't executed. This option is provides the ability to view the structure of a class or object (with the AMEMBERS( ) Function, for example) without opening the class or object in the Class or Form Designer. Note that code in the class or object should never be executed - code execution is not supported and can make Visual FoxPro unstable. You should never explicitly call an event or method, or set properties. Setting properties can call Access and Assign methods.
- eParameter1, eParameter2, ...
- Specifies optional parameters that are passed to the Init event procedure for the class or object.
To assign the object reference returned by NEWOBJECT(В ) to a variable or array element, use the equal sign (=) or STORE command. If an object assigned to a variable or array element is released, the variable or array element contains the null value. To remove the variable or array element from memory, use the RELEASE command.
For NEWOBJECT( ), Visual FoxPro performs an internal SET CLASSLIB or SET PROCEDURE for the second or third parameters using the ADDITIVE clause where the parameters are first used to determine the search order. If these parameters already exist in the SET CLASSLIB or SET PROCEDURE list, Visual FoxPro rearranges the order in the list so they come first. Visual FoxPro then locates all the classes, creates the object, and calls the Init events. Finally, Visual FoxPro restores the original SET CLASSLIB or SET PROCEDURE list if the installation did not change list.
OLE objects are created with the following syntax for cClassName:
For example, to create a Microsoft Excel worksheet, which supports Automation, use the following syntax:
oExcelSheet = NEWOBJECT('Excel.Sheet')