Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NEWOBJECT() vs. CREATEOBJECT()
Message
From
04/02/2004 09:49:31
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00873856
Message ID:
00873888
Views:
25
Einar,

>The question is:
>What is the difference between NEWOBJECT() and CREATEOBJECT()?

The big difference is that NEWOBJECT() allows you to specify the VCX or PRG that the class you want to instantiate resides in, in addition to the APP or EXE if you choose to list the VCX. NEWOBJECT then does an internal SET CLASSLIB TO whatever.vcx ADDITIVE or SET PROCEDURE TO whatever.prg ADDITIVE, instantiates the class, then sets your CLASSLIB or PROCEDURE settings back to the way they were.

It's unfortunate that the help gives just a simple example of instantiating a COM server, which looks just like CREATEOBJECT.

I could, for example, instantiate a class in a PRG like this without having to add BusinessObjects.prg to my SET PROCEDURE settings:

oCust=NEWOBJECT("CustomerBO", "BusinessObjects.prg")

Is there a particular reason you want to use NEWOBJECT with a COM Server? Does CREATEOBJECT not do the job?

You might find the wiki topic helpful:

http://fox.wikis.com/wc.dll?Wiki~NewObject~VFP
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform