[futurebasic] Re: [FB] Function calls with Globals as parameters

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2009 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Thu, 15 Oct 2009 08:26:20 -0700
On Oct 15, 2009, at 6:05 AM, Bill Zielenbach wrote:

> I have a vague recollection of having once been burnt by fn example2  
> so I
> have been using
>
> local fn example3
> dim c#,d#
> c#=gtestparameter#
> d#=fn process#(c#)
> end fn=d#


Bill,

Jay and Robert have given you some good ideas. Here is one more  
thought based on the fn example3 code posted.

In the posted code, there is no need to put the value of  
gTestParameter into a local variable ( i.e. 'c' ) before sending it to  
fn process. Just send it as shown below. fn process then returns a  
value to the caller of fn example3. When  gTestParameter is passed  
like this it is passed by value, meaning the value *in* gTestParameter  
is passed to fn process ( which in the sample code is received as  
myValue ). Changing myValue within fn process does NOT change the  
value of gTestParameter.
'------------------
local fn process ( myValue as double )
// do something with myValue
end fn

local fn example3
end fn =  fn process( gTestParameter )
'------------------

Brian S