[futurebasic] Re: [FB] FB^3 Passing POINT &/or RECT vars.

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2000 : Group Archive : Group : All Groups

From: Chris Stasny <staz@...>
Date: Mon, 21 Feb 2000 14:26:33 -0600
>I really like the ability in FB^3 of creating real records and being able
>to pass them to a local function using something this syntax:
>     LOCAL FN doSomething( aREC AS POINTER TO myRec )
>       ...
>     END FN
>
>What I want to do, is pass variables that were declared as type POINT or
>RECT to a local function in a similar way to above, since they are records
>too. My calling routine has instructions like:
>         FN ConnectPoints( mousePt1, mousePt2 )
>  and    FN FlashRect( playerRect4 )
>
>The compiler gives an unknown variable type error when I try to define the
>functions like any of these: (I had hoped the first two would be
>acceptable.)
>     LOCAL FN ConnectPoints( ptA AS POINT, ptB AS POINT)
>  or LOCAL FN FlashRect( aRect AS RECT )
>  or LOCAL FN FlashRect( aRect AS POINTER TO RECT )
>     etc.
>
>The following didn't give any syntax errors, but just didn't work when called.
>     LOCAL FN FlashRect( aRect AS POINTER )
>         CALL InvertRect( aRect )
>         DELAY 17
>         CALL INVERTRECT( aRect )
>     END FN
>
>The only way I got it to work and use the actual rectangle from the calling
>routine was to have an array variable for the rectangle, like this: (But it
>is just an artificial work-around and not an intuitive programming method).
>I'd really like to 'Keep it Simple & Straight-forward'.
>     LOCAL FN FlashRect( myRect(0) )
>         CALL InvertRect( myRect(0) )
>         DELAY 17
>         CALL INVERTRECT( myRect(0) )
>     END FN
>
>THE QUESTIONS:
>     Am I overlooking something?
>     Is this a bug in FB^3's parameter passing?
>     If so, is it to be changed?


A point is a special kind of record. We had some trouble in the first 
release getting things right. (Fixed now.) A "point" is one of the 
few records that fits in a long integer. So whether we pass the 
address or the actual data is a critical issue in making FB^3 work as 
you expect. I hope the next release solves all of this for you.

In the short term, you can use this...

  LOCAL FN ConnectPoints( @ptA&, @ptB&)
    REM use pointA with    --->   ptA.nil& = newPointVal&



Best,

-STAZ  ~)~

800.348.2623 Orders  http://www.stazsoftware.com
228.255.7086 FAX     mailto:staz@...