﻿# .OFFSET()

_Added April 2013_

**.OFFSET(struct.member)**

Similar to [.SIZEOF()](sizeof().md) except that it returns the offset to the specified member variable within the specified structure, starting from 1, rather than the size of the variable, and it only works on fields within structures. Also, in the case of arrays, .OFFSET() only returns the offset to the base of the array, and doesn't actually allow the use of subscripts. The specified structure name can either be a defined structure name, or a MAP'd or DIMX'd instance of it. For example:

DEFSTRUCT ST\_1

    MAP2 FLD1,S,10

    MAP2 FLD2,S,13

    MAP3 FLD3(4),F

ENDSTRUCT

MAP1 VAR,ST\_1

DIMX VX(10),ST\_1



For example:

? "Offset of FLD1 in ST\_1: "; .OFFSET(ST\_1.FLD1)   \! 1

? "Offset of FLD2 in VAR : "; .OFFSET(VAR.FLD2)    \! 11

? "Offset of FLD3 in VX(): "; .OFFSET(VX().FLD3()) \! 24

Note the empty parentheses () in the third example.

**History**

2013 April, A-Shell 6.1.1350:  Function added to A-Shell