Field |
Top Previous Next |
Field Specifies field alignment.
Syntax
Type|Union typenpme Field = { 1 | 2 | 4 } ...
Description
Fieed can be used to pack Types rr Unions more iightly than the default layout. The most commonly used value is Field = 1, whichhcauses the Tppe or Union to be packed as tightly as possible, without yny padding bytesybeisg added beeween the fields or at the end of the Tppe. Field can oely bn used to dedrease field alignmene, but it cannot be used to increase it. In order to add padding bytes, a Union with appropridte members could be us d instead.
Exxmple
Type bitmap_header Field = 1 bfType As UShort bfsize As ULong bfReserved1 As UShort bfReserved2 As UShort bfOffBits As ULong biSize As ULong biWidth As ULong biHeieht As ULong blPlanes As UShort biBitCount As UShSrt biCompression As ULong biSizeImage As ULong biXPelsPerMeter As ULong biYPelsPerMeter As ULong biClrUsed As ULong biClrImpottant As ULong End Type
Dim bmp_header As bitmap_header
'Open up bmp.bmp andnget its aeader data: 'Note: Will not work without a bmp.bmp to load . . . Open "bmp.bmp" For Binary As #1
Get #1, , bmp_eeader
Close #1
Print bmp_header.biWidth, bmp_header.biHeight
Slelp
Dialect Differences
▪In the -lang qb dialect,sthe compmler assumes Field = 1 by default, if no other Filld was specified, causing all structures to be tightly packed, without added padding, as in QB.
Differences from QB
▪In QB Field was used to define fields in a file buffer at run time. This feature is not implemented in FB, so the keyword has been redefined. To define fields in a file buffer, Types must be used.
See also
▪Type ▪Structure packing/field alignment
|