Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing values by reference

29 views
Skip to first unread message

Rick Lipkin

unread,
May 21, 2012, 3:56:45 PM5/21/12
to
To All

Without giving any small contained example, I would like to know how deeply nested you can pass a variable by reference that can still be evaluated at the top level.

Please consider the below pseudo example .. I can not use any Static or Public variable declarations. It appears that xTotal can be modified in Function Level1 but not any deeper and still seen in Main() with the modified values.

Am I doing something wrong in syntactically passing the parameter below?

Thanks
Rick Lipkin

//------------------
Function Main()

Local xTotal

xTotal := 10.00

.. xTotal equals 10 in Main()
... xTotal should equal 20.00 HERE when modified in Func Level1
... xTotal should equal 30.00 HERE when modified in Func Level2
... xTotal should equal 40.00 HERE when modified in Func Level3

Level1(@xTotal )



//-------------------
Static Func Level1( xtotal )

xTotal := 20.00

Level2( @xTotal )

Return(nil)

//-----------------
Static Func Level2( xTotal )

xTotal := 30.00

Level3( @xTotal )

Return(nil)

//------------------
Static Func Level3( xTotal )

xTotal := 40.00

Return(nil)

ella...@gmail.com

unread,
May 21, 2012, 4:55:04 PM5/21/12
to
Hello,

I think your test code needs to be completed like below ( the functions are cascading... )

Ella

//------------------
Function Main()
Local xTotal
xTotal := 10.00
? "original"
? xTotal
Level1(@xTotal )
? "last"
? xTotal
wait "..."
return NIL


//-------------------
Static Func Level1( xtotal )
? "start level 1 "
? xtotal
xTotal := 20.00
? "continue level 1"
? xTotal
Level2( @xTotal )
? "end level 1"
? xTotal

Return(nil)

//-----------------
Static Func Level2( xTotal )
? "start level 2"
? xTotal
xTotal := 30.00
? "continue level 2"
? xTotal
Level3( @xTotal )
? "end level 2"
? xTotal
Return(nil)

//------------------
Static Func Level3( xTotal )
? "start level 3"
? xTotal
xTotal := 40.00
? "continue level 3"
? xTotal
Return(nil)


dlzc

unread,
May 21, 2012, 6:10:32 PM5/21/12
to
Dear Rick Lipkin:

On Monday, May 21, 2012 12:56:45 PM UTC-7, Rick Lipkin wrote:
>
> Without giving any small contained example, I
> would like to know how deeply nested you can
> pass a variable by reference that can still
> be evaluated at the top level.

As deep as the function stack can go.


> ... I can not use any Static or Public variable
> declarations.

A better way:
http://www.ghservices.com/gregh/clipper/trix0001.htm
... all the visibility and/or protection you might want.

David A. Smith
0 new messages