[futurebasic] Re: [FB] [FB3]SIZEOF Question

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

From: Robert Purves <robert.purves@...>
Date: Tue, 11 Apr 2000 20:46:57 +1200
>I trying to this code below. But two question is
>(Q1)Why TQ3Bitmap size is 9? I think 12...
>(Q2)Why ximage2 size appear? This is not defined. So, I think that error
>must display "This Variable Was Not Defind".And I think these way are much
>better.
>SIZEOF(ximage2) -->Sytanx err. Becuse ximage2 is valiable.
>(Current 3.2.0:No err)
>SIZEOF(TQ3Bitmap2.ximage2) -->collect ximage2 size
>(Current 3.2.0:err)

Q1
There is clearly a bug in FB^3's record size calculation. Where you have
  DIM xxx AS PTR TO yyy
the compiler takes the size of yyy instead the pointer's size (which is 4).
This bug is present in FB^3.2.1.

Q2
In the FB^3 Preferences: Vars, turn the  "Use only DIMensioned variables"
checkbox on. Then the compiler complains properly if you attempt
 PRINT SIZEOF(ximage2). With the checkbox off, a new SHORT variable ximage2
was being created. I recommend leaving that checkbox on _always_.

To find the size of a field in a record, create a record variable and find
the size of its field (see  sizeof (myTQ3Bitmap2.xWidth2) in the code
below).

begin record TQ3Bitmap
dim ximage    as ptr to char // or str255
dim xWidth    as unsigned long
dim xHeight   as unsigned long
end record

begin record TQ3Bitmap2
dim ximage2   as ptr
dim xWidth2   as unsigned long
dim xHeight2  as unsigned long
end record

end globals

dim myTQ3Bitmap as TQ3Bitmap
dim myTQ3Bitmap2 as TQ3Bitmap2
dim myTQ3BitmapArray(10) as TQ3Bitmap
window 1
print "TQ3Bitmap   ";sizeof(TQ3Bitmap) " wrong"
print "myTQ3Bitmap ";sizeof(myTQ3Bitmap) " wrong"
print "ximage      ";sizeof(myTQ3Bitmap.ximage) " wrong"
print "xWidth      ";sizeof(myTQ3Bitmap.xWidth)
print "xHeight     ";sizeof(myTQ3Bitmap.xHeight)
print
print "" @myTQ3BitmapArray(10) - @myTQ3BitmapArray(0) " wrong"
print
print "TQ3Bitmap2   ";sizeof(TQ3Bitmap2)
print "myTQ3Bitmap2 ";sizeof(myTQ3Bitmap2)
print "ximage2      ";sizeof(myTQ3Bitmap2.ximage2)
print "xWidth2      ";sizeof(myTQ3Bitmap2.xWidth2)
print "xHeight2     ";sizeof(myTQ3Bitmap2.xHeight2)
do: until fn button


Robert P.