Positioning of the Element and Element Pointer


See also:

For a list of all Structure functions and related topics, see Structures.

The position of an element within a structure is its offset from the start of the structure. The first element of a structure has an offset of one. The last element of a structure has an offset of n, where n is the total number of elements within the structure.

The element pointer contains an offset into the structure. When a structure is first created, the element pointer has a value of zero. Many command functions use the element pointer value to get, store, or edit structure elements. PEXlib contains a number of functions which modify the position of the element pointer. These requests typically require a {whence, offset} pair. The element pointer is positioned relative to the beginning of the structure (whence == PEXBeginning), relative to the current element pointer position (whence == PEXCurrent), or relative to the end of the structure (whence == PEXEnd). To obtain the absolute offset, the specified offset is added to the position indicated by whence. If the absolute offset is greater than the offset of the last element in the structure, then the element pointer is left pointing to the last element in the structure. For functions which specify a range of elements with two {whence, offset} pairs, the elements affected are those between, and including, the two computed positions regardless of which position was specified first and which was second.

Conceptually, a null element exists before the first element and has an offset of zero and a type of PEXOCNil. Use the value PEXBeginning with an offset of zero to set the element pointer to this position. See PEXElementSearch for a discussion on the usage of PEXOCNil in searches.

A label is a special structure element that allows convenient editing of a structure. A pick identifier is similar to a label. It is returned as part of the pick path and is used to aid in identifying the selected object. Labels and pick identifiers are stored as structure elements and move with other structure elements as you insert or delete elements before them in the structure. You can move the element pointer within a structure to a specific offset, a particular label element, a particular pick identifier element, or the next location of a particular type of structure element.