[futurebasic] Re: [FB] True Records and Field Offsets Dynamically

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2007 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Fri, 24 Aug 2007 15:20:18 +1200
maxclass@... wrote:

> begin record TrueRecord
>   dim as short aShort
>   dim as long aLong
>   dim as single aSingle
>   dim as double aDouble
> end record
>
> myPtr = FN NewPtrClear( sizeof( TrueRecord ) )
>
> Now I have a pointer to a block of memory the size of my  
> TrueRecord. So far so good.
> But, I need to get the offset into that block of memory that gives  
> me the location of any field defined within the original TrueRecord  
> so that I can use some syntax akin to the following.
> myPtr.aLong = _zTrue		// etc. [which does not work]
> This always returns an undefined field error.

You don't show the declaration of myPtr. It should be:
dim myPtr as ^TrueRecord
Then you can reference fields in the pointer block exactly as though  
it were a variable of type TrueRecord.

Robert P.