[futurebasic] Re: [FB] Function functionality

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2011 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Tue, 24 May 2011 22:40:43 +1200
Dan Baeckström wrote:

> I have previously been shown here how values can be returned from local fns using pointers to variables
> 
> local fn sillydemo(a as short, b as ^short,c as ^double)
> b.0% = 2*a
> c.0# = pi*a
> end fn
> 
> dim as short x
> dim as double y
> fn sillydemo(3,@x,@y)
> print x,y
> 
> My next question is: how is the corresponding thing achieved when I want the fn to return an FSRef?



'--------------------
include "Util_FileDirectory.incl"

local fn Foo( f as ^FSRef )
'~'1
fn FD_ApplicationDirectoryGetFSRef( #f ) 
// '#' above means pass the value of f, not its address; f is already a pointer
end fn


dim as FSRef    ref
fn Foo( @ref ) 
// '@' above means 'pass the address of ref'.
// It is not actually needed in this case, because FBtoC
// automatically supplies it when the variable is a record.

'...do something with ref...
'---------------------

Robert P.