Hi Marcia.
>>> The only problem with NewObject is that it's considerably slower than CreateObject. <<
>
>Is that always true? I thought that if you used NewObject() and the specified Classlib was already loaded into memory, that it could be even faster that CreateObject(). Or am I on Mars with this one <g> ?
It's been a while since I last tested this, but here's the process underlying NEWOBJECT():
- close all opened class libraries
- open the specified one
- instantiate the class
- close the specified class libraries
- reopen the previously open ones
IMO, this is just dumb -- it should check to see if the specified class library is already open and use it if so.
You can prove that this is the behavior by doing this:
SET CLASSLIB TO (some VCX not in path or curdir)
X = NEWOBJECT('someclass', 'VCX opened in previous line')
You'll get a "file whatever.vcx does not exist" error.
Since VFP has to close and reopen all those class libraries on every call to NEWOBJECT(), it ought to be slower than CREATEOBJECT().
Doug