[futurebasic] Re: [FB] Passing parameters from function to function

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2005 : Group Archive : Group : All Groups

From: Brian Stevens <brilor@...>
Date: Thu, 7 Jul 2005 07:11:37 -0700

On Jul 7, 2005, at 3:33 AM, Bernie wrote:
>
> Anyway, I have a general question regarding passing parameters to  
> and from functions... In the example, I want(ed) to eliminate the  
> need to dim and copy the boolean. I've tried variations of the  
> following:
>
> ..., @set as ^Boolean )
> ... sizeof( Boolean ), #set )
>
> but I either get a compile error or a crash.
>
> Any suggestions?
>
> Bernie
>
>
> '----------
> /*
>    Wrapper for def SetButtonData(...PushButtonDefaultTag...)
> */
> local mode
> local fn PushButtonSetDefault( btnID as long, set as Boolean )
> '~'1
> dim as Boolean  @ bool
>
> bool = set
> end fn = fn SetControlData( button&( btnID ),  
> _kControlEntireControl, _kControlPushButtonDefaultTag, sizeof 
> ( Boolean ), bool )
>
>
> err = fn PushButtonSetDefault( _cBtn, _true )
> '----------


Bernie,  since you are passing a constant (_true), you need to have a  
ram-based local copy inside the FN. The constant is almost certainly  
passed by value (and not by address/reference), so trying to pass the  
constant won't work (because you would be passing the value of the  
constant--0 or 1--as an address----and using/modifying that address  
is not in the applications owned address space). Oops, just noted  
Alain gave you a more elaborate answer. Anyway, I don't see any real  
issue with making a local copy of the boolean. Why the need/desire to  
eliminate it?

Brian