Previous Next Up Title Contents Index Functions Index Top Library

1.3.2. EDIT STRUCTURE


This phase in an application consists of creating, modifying, or cancelling structures.

Elements in a structure may be modified by editing the structure. Editing a structure may involve any of the following operations:

- inserting a new element

- replacing one element with another

- deleting an element

- copying an element

- recovering the contents of an element.

To understand the principle of GPHIGS structure editing, it is possible to compare it with editing a file in a text editor. The left-hand column below shows the various notions associated with structure editing and the right hand column gives the equivalent in a text editor.

edit structure edit text

open structure open file in editor

close structure close current file in editor

structure element file character

element pointer cursor position

edit mode insert or replace character mode

label marking marker in editor

delete element delete characters

1.3.2.1. START AND END EDIT

To start editing, just open the required structure by calling the function POPST (struct_id). Editing a structure is ended when the function PCLST is called. Only one structure may be open at a given time.

1.3.2.2. ELEMENT POINTER

A structure is a series of elements. The position of these elements is implicitly numbered from 1 to N ; position 1 corresponds to the first element. Numbers are always in consecutive, increasing order (no gaps), with one number for each element. The position number associated with a particular element will therefore change in function of insertions and deletions during editing.

The element pointer is similar to the position cursor of a text editor. It shows the position in the structure where the next modification (insertion of a new element or replacement or destruction of an existing element) is to be carried out. When a structure is opened the element pointer is initialized :

- at the position of the last element in the structure if the structure is not empty prior to opening

- at 0 if the structure is empty

The PQEP inquire element pointer function gives the current value of the element pointer.

The PSEP(n) set element pointer function positions the element pointer at the nth element in the open structure. This is the absolute position of the pointer.

The POSEP(n) offset element pointer function increases (where n > 0) or decreases (where n <0) the value of the element pointer. This is the relative position of the pointer in relation to its previous value.

The PSEPLB(n) set element at label function positions the element pointer on the next label-type element in the structure with a value n. A label-type element with a value n is inserted in a structure by calling the PLB(n) function. Several label-type elements may be included in the same structure. Criteria for moving to the PSEPLB function are as follows:

If the element pointer is already on a label, the function looks for the next label with a value n, starting with the next element. Otherwise, the element pointer starts looking from its current position. If the element pointer does not find another label, it keeps the same value.

The following diagram shows the 3 ways the element pointer can move.

1.3.2.3. INSERTING OR REPLACING AN ELEMENT

When a structure is open, the application program may insert new elements or replace existing elements by calling the following simple functions : PTX, PSPLCI, PEXST, etc....

The PSEDM set edit mode function specifies whether new elements replace the element indicated by the element pointer or if they are added after the existing element. In all cases, the element pointer points to the new element, as shown in the following 2 diagrams.

1.3.2.4. DESTROY ELEMENT

GPHIGS provides three functions for destroying one or more elements in a structure:

- PDEL delete element

- PDELRA delete element range

- PDELLB delete elements between labels

PDEL deletes the element indicated by the element pointer . If the value of the element pointer is zero, no elements are deleted.

PDELRA (i,j) deletes all the elements between the i-th element and the j-th element

PDELLB (i,j) deletes the elements between the following two labels in the structure with values of i and j respectively. The labels are not deleted.

After each of the preceding three functions, the element pointer points to the element immediately preceding the element or the group of elements which has been deleted.

The PEMST(STRID), empty structure function may also be used to delete all the elements in the structure with the STRID identifier without affecting any references which may be made to this structure.

This diagram shows the various types of operations which may be carried out on structures.


Previous Next Up Title Contents Index Functions Index Top Library