INFO: NewObject Command Respects the SET PROCEDURE Command
ID: Q189603
|
The information in this article applies to:
-
Microsoft Visual FoxPro for Windows, version 6.0
SUMMARY
The NewObject function temporarily overrides the SET CLASSLIB and SET
PROCEDURE commands in order to create an object from a specific class and
class library. The SET PROCEDURE TO setting is retained, however, during
the initialization of the NewObject object, in the event that the
information in a procedure is required.
MORE INFORMATION
In the following example, an object instantiated using the NewObject
command calls a procedure located in a .prg file:
- Create a class named ProcTest in a class library name SetProcTest as
follows:
CREATE CLASS ProcTest of SetProcTest as Custom
- In the Init Event of ProcTest, place the following code and save the
class:
lcValue = InitFunction()
MESSAGEBOX(lcValue)
- Create a procedure called TestProg with the following code:
PROCEDURE InitFunction
RETURN "Hello"
- In the Command window, issue the following commands:
SET PROCEDURE to TestProg
oProcTest = NEWOBJECT("ProcTest", "SetProcTest")
Although the NewObject function performs its own SET CLASSLIB and SET
PROCEDURE commands, in order to instantiate an object, the ability to use
SET CLASSLIB or SET PROCEDURE settings previously invoked allows additional
flexibility in this command. The SET CLASSLIB and SET PROCEDURE commands
remain available to the NewObject command and do not have to be re-issued
during the instantiation of an object.
Additional query words:
kbVFp600 kbOOP
Keywords :
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbinfo