dbTalk Databases Forums  

VFP 6: Derived Properties

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss VFP 6: Derived Properties in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene Wirchenko
 
Posts: n/a

Default VFP 6: Derived Properties - 10-12-2004 , 03:18 PM






I am reading Markus Egger's "Advanced Object Oriented Programming
with Visual FoxPro 6.0". On page 335, he discusses derived
attributes/properties and gives some sample code. Unfortunately, it
is only a snippet.

I put something together myself. This works to the extent of
giving me the right answer.

Must I define c as a property? (If I have multiple derived
red-only properties, I would just as soon not define them.) Without
it, I get an error "Property C is not found." Is there another way to
do it? I looked at this_access, but the documentation is rather
opaque.

********** Start of Included Code **********
* Derived Property

o=createobject("derived")

o.a=3
o.b=4

? o.c

return

define class derived as custom

a=.f.
b=.f.
c=.f.

procedure c_access
return sqrt(this.a*this.a+this.b*this.b)
endproc

enddefine
********** End of Included Code **********

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.

Reply With Quote
  #2  
Old   
Fred Taylor
 
Posts: n/a

Default Re: VFP 6: Derived Properties - 10-12-2004 , 08:57 PM






Since it's trying to print an object property (?o.c), then "c" must be a
property of that class. It must still be defined, even if you just give it
a default value. You can't have an _access method unless there's a property
for it to access!

--
Fred
Microsoft Visual FoxPro MVP


"Gene Wirchenko" <genew (AT) mail (DOT) ocis.net> wrote

Quote:
I am reading Markus Egger's "Advanced Object Oriented Programming
with Visual FoxPro 6.0". On page 335, he discusses derived
attributes/properties and gives some sample code. Unfortunately, it
is only a snippet.

I put something together myself. This works to the extent of
giving me the right answer.

Must I define c as a property? (If I have multiple derived
red-only properties, I would just as soon not define them.) Without
it, I get an error "Property C is not found." Is there another way to
do it? I looked at this_access, but the documentation is rather
opaque.

********** Start of Included Code **********
* Derived Property

o=createobject("derived")

o.a=3
o.b=4

? o.c

return

define class derived as custom

a=.f.
b=.f.
c=.f.

procedure c_access
return sqrt(this.a*this.a+this.b*this.b)
endproc

enddefine
********** End of Included Code **********

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.



Reply With Quote
  #3  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: VFP 6: Derived Properties - 10-12-2004 , 11:14 PM



"Fred Taylor" <ftaylor (AT) mvps (DOT) org!REMOVE> wrote:

Quote:
Since it's trying to print an object property (?o.c), then "c" must be a
property of that class. It must still be defined, even if you just give it
a default value. You can't have an _access method unless there's a property
for it to access!
Thank you. I was not totally sure.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.