Replacing Structure Elements


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

Overwrite existing structure elements by setting the editing mode of a structure to PEXStructureReplace. In replace mode, existing elements are deleted and the new elements sent to the structure are created in their place. The number of elements deleted is equal to n, where n is the number of elements sent to the structure in a single request (unless there are fewer than n elements between the element pointer position and the end of the structure, in which case only those between the element pointer position and the end of the structure are deleted). If the range to be deleted includes offset 0 then n-1 elements are deleted from the structure. The elements sent to the structure are then inserted in place of the deleted elements. After each replace operation, the element pointer is updated to point to the last newly-replaced element.

Because PEXlib groups the OC's generated by your OC function calls in unpredictable ways, you often cannot be certain that a series of OC function call invocations that replace elements in a structure are handled in one request to the PEX implementation. Because the element pointer is left at the last replaced element and a replace request begins with the current element, a replace operation divided into multiple requests may cause the element at the tail end of one request to be replaced by the first element of the next request. Therefore, to be completely safe, you should use the PEXOCStoreSingle request type in the OC function argument list and update the element pointer after replacing each element to move the element pointer to the next element to prepare to replace it. Another, perhaps more efficient, approach is to delete n elements from the structure and then invoke the n OC functions to insert the new elements in the place of the deleted elements. You use PEXOCStore in replace mode only if you are certain that a string of OC function calls will generate a single request, as in the case of replacing several small attribute or primitive output commands.

See also: Positioning of the Element and Element Pointer.