Home > Archive > Programming with dBASE > April 2005 > Re: How can assign a reference to a property to a property in another class?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How can assign a reference to a property to a property in another class?
Frank J. Polan

2005-04-19, 8:23 pm

Luis

Run this as a prg. Does it give what you want?

Frank Polan

.....................................................
local oA
oA = new A()
?oA.oSoma1.soma(oA.prop1a, oA.prop1b) // <---returns 3
oA.prop1a=5
?oA.oSoma1.soma(oA.prop1a, oA.prop1b) // returns 7
// <---returns 3, I would like it to return 7

class A
this.prop1a=1
this.prop1b=2
this.prop2a=10
this.prop2b=20


this.oSoma1 = new B()
with this.oSoma1
propx = this.prop1a // <---assigns by value
propy = this.prop1b
endwith

this.oSoma2 = new B()
with this.oSoma2
propx = this.prop2a
propy = this.prop2b
endwith

endclass

class B

function soma(propx, propy)
local x
x = propx + propy
return x
endclass

..................................................................................

On Tue, 19 Apr 2005 18:27:08 +0100, Luis <luis.guedes@sapo.pt> wrote:

>I would like to have something like the code below but to do that I
>would need to be able to assign a reference to a property and not the
>current value. I've tried passing parameters with the same result.
>Can someone please point me to the right direction?
>
>Thanks in advance
>Luís
>
>
>
>local oA
>oA = new A()
>
>?oA.oSoma1.soma() // <---returns 3
>oA.prop1a=5
>?oA.oSoma1.soma() // <---returns 3, I would like it to return 7
>
>class A
> this.prop1a=1
> this.prop1b=2
> this.prop2a=10
> this.prop2b=20
>
> this.oSoma1 = new B()
> with this.oSoma1
> propx = this.prop1a // <---assigns by value
> propy = this.prop1b
> endwith
>
> this.oSoma2 = new B()
> with this.oSoma2
> propx = this.prop2a
> propy = this.prop2b
> endwith
>
>endclass
>
>class B
> this.propx = null
>
> this.propy = null
>
> function soma()
> local x
> x = this.propx + this.propy
> return x
>endclass


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com