[futurebasic] Re: [FB] Rectangle Problems

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

From: Alain Pastor <apastor@...>
Date: Tue, 04 Jul 2000 10:50:59 +0200

"macbse.com" wrote:

>
>     Thanks, the blockmove code is more applicable as the code for moving
> the rectangle into other variales gets used a lot in other areas of the
> code.
>
>   The code now looks like this:
>
> LOCAL FN delSection(ParamHndl&)
>   DIM drawRect;8
>   drawRect;8 = @ParamHndl&..displayRect.top%
>   PRINT drawRect.top%
>   PRINT drawRect.left%
>   PRINT drawRect.bottom%
>   PRINT drawRect.right%
>
>   CALL ERASERECT(drawRect)
>
> END FN
>
> CALL SETRECT(aParamBlock.displayRect, 10, 10, 400, 200)'Set display rect
>
> FN delSection(@aParamBlock)                            'Delete the area
>
>   When I get the printout of whats in drawRect I get 16615, 124, 1792,
> 2201 which is not what I put in there in the first place. What's gone
> wrong?
>
>

Hello Ashley,

It is difficult for me to see what's happening without seeing more code but for
sure you are not accessing the good places in memory. I've built for you a
little example, but I don't know if it can apply to your case. It seems to work,
so perhaps you could learn from it:

'Dummy structure for the example
DIM RECORD myRec
  DIM field1%
  DIM field2$
  DIM displayRect.8
  DIM lastfield&
DIM END RECORD.recSize

END GLOBALS
'===========================
LOCAL FN initBlock
  DIM myHandle&

  myHandle& = FN NEWHANDLE _clear(_recSize)                   'ask for a handle
  LONG IF myHandle&
    myHandle&..field1% = 1                                    'we can access the
fields
    myHandle&..field2$ = "two"                                'starting with the
handle
    myHandle&..lastfield& = 4                                 'and the double
dot syntax
    CALL SETRECT(myHandle&..displayRect.top%,10,10,400,200)
  END IF

END FN = myHandle&
'===========================
LOCAL FN displayBlock(ParamHndl&)
  DIM drawRect.8                                              'set aside 8 bytes


  drawRect;8 = @ParamHndl&..displayRect.top%                  'move 8 bytes from
handle to drawrect
  PRINT "field1% =";ParamHndl&..field1%
  PRINT "field2$ =";ParamHndl&..field2$
  PRINT "lastfield =";ParamHndl&..lastfield&
  CALL FRAMERECT(drawRect.top%)

END FN
'===========================

WINDOW 1
DIM aParamBlock&                                              'will hold our
handle
aParamBlock& = FN initBlock                                   'get and fill our
handle
FN displayBlock(aParamBlock&)                                 'display the
values
DO
  HANDLEEVENTS
UNTIL FN BUTTON
IF aParamBlock& THEN DEF DISPOSEH(aParamBlock&)
END


Cheers

Alain