Discussion:
Declaring variable as "Empty" ???
m***@mbsoftwaresolutions.com
2018-01-30 18:50:57 UTC
Permalink
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).

???

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/***@mbsoftwaresolutions.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Stephen Russell
2018-01-30 20:00:33 UTC
Permalink
Still trying to think of why you would use it.

On Tue, Jan 30, 2018 at 12:50 PM, <
Post by m***@mbsoftwaresolutions.com
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]

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAJidMY+0wLXKp5eNeR-G7s8u2f=JijpB1gXzZSTTc-bcOuRM=***@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Frank Cazabon
2018-01-30 20:12:37 UTC
Permalink
I've seen it used as a lightweight class.

http://fox.wikis.com/wc.dll?Wiki~EmptyClass
Post by m***@mbsoftwaresolutions.com
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]

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/BE625619-E0CF-4E9B-8F97-***@gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
m***@mbsoftwaresolutions.com
2018-01-30 21:09:06 UTC
Permalink
Post by Frank Cazabon
I've seen it used as a lightweight class.
http://fox.wikis.com/wc.dll?Wiki~EmptyClass
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.

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/***@mbsoftwaresolutions.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Paul H. Tarver
2018-01-30 22:44:16 UTC
Permalink
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-***@leafe.com] On Behalf Of Frank
Cazabon
Sent: Tuesday, January 30, 2018 2:13 PM
To: ***@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,
Post by m***@mbsoftwaresolutions.com
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]

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/072801d39a1b$dbe2ba60$93a82f20$@tpcqpc.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Fernando D. Bozzo
2018-01-30 22:56:07 UTC
Permalink
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.-
Post by Paul H. Tarver
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
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-----
Cazabon
Sent: Tuesday, January 30, 2018 2:13 PM
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,
Post by m***@mbsoftwaresolutions.com
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]

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAGQ_JukMt3cL8y0bmxDaufSGqZ1r0-***@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Fernando D. Bozzo
2018-01-30 23:02:23 UTC
Permalink
A small error writing by heart, but EMPTY class has no AddProperty()
method, so really is:

AddProperty( loReg, "name", value)
...
Post by Fernando D. Bozzo
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
* 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.-
Post by Paul H. Tarver
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
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-----
Cazabon
Sent: Tuesday, January 30, 2018 2:13 PM
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,
Post by m***@mbsoftwaresolutions.com
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]

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAGQ_Junj8KFoa7DFNmiH5hNBMCMN468tEKOHbX46m8o=***@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
m***@mbsoftwaresolutions.com
2018-01-31 01:36:49 UTC
Permalink
Post by Fernando D. Bozzo
A small error writing by heart, but EMPTY class has no AddProperty()
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.

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/***@mbsoftwaresolutions.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Ted Roche
2018-01-30 22:00:14 UTC
Permalink
On Tue, Jan 30, 2018 at 1:50 PM,
Post by m***@mbsoftwaresolutions.com
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.
--
Ted Roche
Ted Roche & Associates, LLC
http://www.tedroche.com

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CACW6n4uLWLR-qjx3==CA_NUX9u09-***@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Gene Wirchenko
2018-01-31 00:05:39 UTC
Permalink
Post by Stephen Russell
Still trying to think of why you would use it.
Likewise.

If I want a data object, I usually also want methods. I
subclass custom so I can have this. At the very least, I want the
object initialised so I want .init(). Having to initialise outside
of the object is not very OOP!

[snip]

Sincerely,

Gene Wirchenko


_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/***@mtlp000083
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Loading...