Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP9.0 Beta new Newobject syntax use

Status
Not open for further replies.

glennpd

Programmer
Jul 2, 2001
5
US
VFP 9.0 allows creating an object but without INIT. using the following syntax:

Lo = Newobject('MyClass','MyClasslib',0)

Can this technique be used simulate a designer and facilitate the WriteMethod method? If not, does anyone have any "good" proctical uses for this new feature?

Thanks

Glenn
 
glennpd

VFP 9.0 allows creating an object but without INIT. using the following syntax:
Lo = Newobject('MyClass','MyClasslib',0)

I'm not sure what without INIT means, but NEWOBJECT() was introduced in VFP7.0.

I'm not sure how that relates to the WriteMethod which is and always was available at design time not at runtimee.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Genn,

I haven't seen this feature yet, but it's hard to think of a reason to use it. It suggests that the person who wrote the class wanted it to perform some action at Init time, but the person intantiating the class didn't want to perform that action.

Also, the syntax is hard to follow. The third param to Newobject() is normally the module name (typically, a VCX). In the syntax that you showed, there would be no opportunity to specify the module name.

In short, the whole thing sounds a bit odd. Perhaps you could clarify?

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
On several instances I just want to extract PEM's from active objects (amembers.) I think the intent is to have a lightweight operation so information about the object can be determined and operations performed ‘on’ the object without instantiating a production copy. I haven’t used this calling syntax yet so I really can’t give a reply based on experience. At this point I’m still making sure none of my VFP8 code breaks!
 
According to the VFP9.0 Beta documentation the syntax for the NewObject function is as follows:

" NEWOBJECT( ) Creates Objects without Raising Initialization Code
To mimic the behavior of a class opened in the Class Designer or Form Designer, pass 0 to the cInApplication parameter. This feature allows you to create design-time tools that view the structure of a class.
By passing 0 to the cInApplication parameter for the NEWOBJECT( ) function, Visual FoxPro allows you to create an instance of a class without raising initialization code (such as code in the Init, Load, Activate, and BeforeOpenTables events). Furthermore, when the object is released, it does not raise its destructor code (such as code in the Destroy and Unload events). Only initialization and destructor code is suppressed; code in other events and methods is still called.

If you use the cInApplication parameter to suppress initialization and destructor code in an object, you also suppress it in the object's child objects.

This behavior is not supported for the NEWOBJECT method.

If you want to create a new object using a class definition specified in a generated application (.app) file, you can use the SET PROCEDURE command to load your user-defined class into memory."

Glenn





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top