FutureBasic Logo

<<    Index    >> FutureBasic 5

offsetof   function



Syntax:
byteOffset = offsetof(fieldName in {recordType|trueRecVar})
byteOffset = offsetof(const [in pseudoRecVar])


Description:
Use this function to find where a particular field begins within a record. offsetof returns the field's offset as a number of bytes past the beginning of the record.
In the first syntax, recordType is the name of a "true record" type as defined in a begin record statement; trueRecVar is a variable declared as a "true record" type; fieldName is the name of a field within that "true record" type.
In the second syntax, const is a symbolic integer constant, without its leading underscore character. Typically, this will be a constant which was defined within a dim record...dim end record block. pseudoRecVar.recLen is a "pseudo-record" variable declared as dim psuedoRecVar.recLen. When you use the second syntax, offsetof just returns the value of const. Because a symbolic constant always has a global scope, the in pseudoRecVar clause is not required.
The value passed as fieldName is seen by the compiler as a constant. You do not use type designator suffixes like $,&,#, etc.

See Also:
sizeof; typeof; begin record; dim record; Appendix C - Data Types and Data Representation