Saw this today while looking for other stuff: https://www.screencast.com/t/PyvZvy53oZFu
Never saw anyone declare a variable AS "Empty" before? I guess that's basically this: loMenuItem = CREATEOBJECT("Empty") (although you'd still have to write that code, of course, since no instantiation in declaration in VFP).
???
Still trying to think of why you would use it.
On Tue, Jan 30, 2018 at 12:50 PM, < mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
Saw this today while looking for other stuff: https://www.screencast.com/t/PyvZvy53oZFu
Never saw anyone declare a variable AS "Empty" before? I guess that's basically this: loMenuItem = CREATEOBJECT("Empty") (although you'd still have to write that code, of course, since no instantiation in declaration in VFP).
???
[excessive quoting removed by server]
I've seen it used as a lightweight class.
http://fox.wikis.com/wc.dll?Wiki~EmptyClass
On 30 January 2018 14:50:57 GMT-04:00, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
Saw this today while looking for other stuff: https://www.screencast.com/t/PyvZvy53oZFu
Never saw anyone declare a variable AS "Empty" before? I guess that's basically this: loMenuItem = CREATEOBJECT("Empty") (although you'd still have to write that code, of course, since no instantiation in declaration in VFP).
???
[excessive quoting removed by server]
On 2018-01-30 15:12, Frank Cazabon wrote:
I've seen it used as a lightweight class.
Oh I've often used the Empty class as well; very useful. Just curious why the declaration was as such. Penchant for correctness I guess.
I think I accidently did something similar recently and I think using createobject('Empty') may have been a cleaner method of doing what I did.
I was trying to create an object I could use to store say a dozen or more attributes and then pass the reference to the object as one parameter rather than a dozen or more separate parameters. This need comes up from time to time when I want to build a complex method that uses only parameters to do the same job repeatedly as I fall through a large table. In this specific situation, I was looping through 50 or 60 columns on about 1,000 records. Not sure if there is any performance benefit one way or another in using lots of parameters as compared to using an object references, but it sure made the development of the two-part processing a lot easier.
The way I did it was to add a custom object to my Class Library and then use NewObject to create the object within my main code like this:
loTaxObject = NEWOBJECT("Std_VarObj","toolkit") loTaxObject.AddProperty('ocClientId', '') loTaxObject.AddProperty('ocEmplId', '') loTaxObject.AddProperty('ocEmplName', '') .... etc.
I then fall through a scan...endscan routine where we populate the various properties on the object and then pass the loTaxObject as a parameter to a different method which then uses all of the properties to the final processing. Not sure whether this is good programming style or not, but it worked like I wanted and I think I'll be using something like this again in the near future. Then I saw the CreateObject('Empty') command mentioned on this thread.
Wouldn't that accomplish the same thing I did via NewObject with a pre-established class?
Thanks!
Paul
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Frank Cazabon Sent: Tuesday, January 30, 2018 2:13 PM To: profoxtech@leafe.com Subject: Re: Declaring variable as "Empty" ???
I've seen it used as a lightweight class.
http://fox.wikis.com/wc.dll?Wiki~EmptyClass
On 30 January 2018 14:50:57 GMT-04:00, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
Saw this today while looking for other stuff: https://www.screencast.com/t/PyvZvy53oZFu
Never saw anyone declare a variable AS "Empty" before? I guess that's basically this: loMenuItem = CREATEOBJECT("Empty") (although you'd still have to write that code, of course, since no instantiation in declaration in VFP).
???
[excessive quoting removed by server]
Declaring a variable as "EMPTY" is the same as declaring as "object": As Ted said, has no programmatic effects, but in this case has no effect even for Intellisense.
When I want Intellisense for an EMPTY object I define a CUSTOM class with the properties of the EMPTY object, so I (or the team) can benefit of Intellisense for the EMPTY object, like this example:
* TEST.PRG LOCAL loReg as C_REG OF TEST.PRG loReg = CREATEOBJECT("EMPTY") loReg.AddProperty("name", value) loReg.AddProperty("address", value) ... RETURN
DEFINE CLASS C_REG AS CUSTOM name = "" address = "" ENDDEFINE
In some situations this is very useful.
Fernando.-
2018-01-30 23:44 GMT+01:00 Paul H. Tarver paul@tpcqpc.com:
I think I accidently did something similar recently and I think using createobject('Empty') may have been a cleaner method of doing what I did.
I was trying to create an object I could use to store say a dozen or more attributes and then pass the reference to the object as one parameter rather than a dozen or more separate parameters. This need comes up from time to time when I want to build a complex method that uses only parameters to do the same job repeatedly as I fall through a large table. In this specific situation, I was looping through 50 or 60 columns on about 1,000 records. Not sure if there is any performance benefit one way or another in using lots of parameters as compared to using an object references, but it sure made the development of the two-part processing a lot easier.
The way I did it was to add a custom object to my Class Library and then use NewObject to create the object within my main code like this:
loTaxObject = NEWOBJECT("Std_VarObj","toolkit") loTaxObject.AddProperty('ocClientId', '') loTaxObject.AddProperty('ocEmplId', '') loTaxObject.AddProperty('ocEmplName', '') .... etc.
I then fall through a scan...endscan routine where we populate the various properties on the object and then pass the loTaxObject as a parameter to a different method which then uses all of the properties to the final processing. Not sure whether this is good programming style or not, but it worked like I wanted and I think I'll be using something like this again in the near future. Then I saw the CreateObject('Empty') command mentioned on this thread.
Wouldn't that accomplish the same thing I did via NewObject with a pre-established class?
Thanks!
Paul
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Frank Cazabon Sent: Tuesday, January 30, 2018 2:13 PM To: profoxtech@leafe.com Subject: Re: Declaring variable as "Empty" ???
I've seen it used as a lightweight class.
http://fox.wikis.com/wc.dll?Wiki~EmptyClass
On 30 January 2018 14:50:57 GMT-04:00, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
Saw this today while looking for other stuff: https://www.screencast.com/t/PyvZvy53oZFu
Never saw anyone declare a variable AS "Empty" before? I guess that's basically this: loMenuItem = CREATEOBJECT("Empty") (although you'd still have to write that code, of course, since no instantiation in declaration in VFP).
???
[excessive quoting removed by server]
A small error writing by heart, but EMPTY class has no AddProperty() method, so really is:
AddProperty( loReg, "name", value) ...
2018-01-30 23:56 GMT+01:00 Fernando D. Bozzo fdbozzo@gmail.com:
Declaring a variable as "EMPTY" is the same as declaring as "object": As Ted said, has no programmatic effects, but in this case has no effect even for Intellisense.
When I want Intellisense for an EMPTY object I define a CUSTOM class with the properties of the EMPTY object, so I (or the team) can benefit of Intellisense for the EMPTY object, like this example:
- TEST.PRG
LOCAL loReg as C_REG OF TEST.PRG loReg = CREATEOBJECT("EMPTY") loReg.AddProperty("name", value) loReg.AddProperty("address", value) ... RETURN
DEFINE CLASS C_REG AS CUSTOM name = "" address = "" ENDDEFINE
In some situations this is very useful.
Fernando.-
2018-01-30 23:44 GMT+01:00 Paul H. Tarver paul@tpcqpc.com:
I think I accidently did something similar recently and I think using createobject('Empty') may have been a cleaner method of doing what I did.
I was trying to create an object I could use to store say a dozen or more attributes and then pass the reference to the object as one parameter rather than a dozen or more separate parameters. This need comes up from time to time when I want to build a complex method that uses only parameters to do the same job repeatedly as I fall through a large table. In this specific situation, I was looping through 50 or 60 columns on about 1,000 records. Not sure if there is any performance benefit one way or another in using lots of parameters as compared to using an object references, but it sure made the development of the two-part processing a lot easier.
The way I did it was to add a custom object to my Class Library and then use NewObject to create the object within my main code like this:
loTaxObject = NEWOBJECT("Std_VarObj","toolkit") loTaxObject.AddProperty('ocClientId', '') loTaxObject.AddProperty('ocEmplId', '') loTaxObject.AddProperty('ocEmplName', '') .... etc.
I then fall through a scan...endscan routine where we populate the various properties on the object and then pass the loTaxObject as a parameter to a different method which then uses all of the properties to the final processing. Not sure whether this is good programming style or not, but it worked like I wanted and I think I'll be using something like this again in the near future. Then I saw the CreateObject('Empty') command mentioned on this thread.
Wouldn't that accomplish the same thing I did via NewObject with a pre-established class?
Thanks!
Paul
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Frank Cazabon Sent: Tuesday, January 30, 2018 2:13 PM To: profoxtech@leafe.com Subject: Re: Declaring variable as "Empty" ???
I've seen it used as a lightweight class.
http://fox.wikis.com/wc.dll?Wiki~EmptyClass
On 30 January 2018 14:50:57 GMT-04:00, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
Saw this today while looking for other stuff: https://www.screencast.com/t/PyvZvy53oZFu
Never saw anyone declare a variable AS "Empty" before? I guess that's basically this: loMenuItem = CREATEOBJECT("Empty") (although you'd still have to write that code, of course, since no instantiation in declaration in VFP).
???
[excessive quoting removed by server]
On 2018-01-30 18:02, Fernando D. Bozzo wrote:
A small error writing by heart, but EMPTY class has no AddProperty() method, so really is:
AddProperty( loReg, "name", value) ...
I've always just used ADDPROPERTY(object, field, value)...I've never used the .AddProperty of any legitimate object. I don't see any advantage over using the 1st.
On Tue, Jan 30, 2018 at 1:50 PM, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
Never saw anyone declare a variable AS "Empty" before?
Declaring a variable AS a type has no programmatic effects, but it does make Intellisense(R), based on the class definition, work for the object.