• Keine Ergebnisse gefunden

SYSFILE STATIC EXTERNAL 2 SCRATCH FILE VARIABLE,

Im Dokument ::-:0==0 (Seite 132-136)

DECLARE X LABEL VARIABLE:

DECLARE 1 SYSFILE STATIC EXTERNAL 2 SCRATCH FILE VARIABLE,

2 CURRENT FILE VARIABLE, 2 STATIC FILE VARIABLE;

An entity that is an element of a set is said to be a mellb!!r of the set. An entity may be the member of one or more sets having the same name or different names. Since sets are ordered, the programmer can reference the first, second, or last member (entity) of a set. Also, since a set mayor may not be homogenous, it makes sense to talk about the first or second member of a set of a particular type. Entities may also contain of one or more sets, provided each set has a different name. In the case of a named set owned by an entity-variable, many generations of the set can exist in the same file. However, only one generation of a named FILE_SET may exist in a file.

A set cannot be allocated or freed. When the INSERT statement is first used to make an entity a member of a set, the set will automatically be created. Similarly, if all .embers of a set are removed, the set will be deleted.

130 Chapter 6 -- File Handling

31 rURCH 1912

The INSERT statement is used to include a generation of an entity as a member of a particular set. Any entity may be inserted as a member of any set. Hence, a set may contain many generations of the same entity or many different entities. An entity can also be inserted onto more than one set. The first entity inserted into a set will be the fiLst member.

Because sets are ordered, i t also is possible to specify a position that an entity is to assume as a member of a set.

The BEFORE, AFTER, FIRST, and LA~T clauses of the INSERT statement allow the proqrammer to specify a relative posi-tion at which to make the insertion. If the membeLs of a set are numbered (1,2,3) and a new entity is inserted after entity 2, i t will become member 3 and the previous member 3 will become number 4.

Example:

nECtARE (P1,P2) POINTER, POINT ENTITY (P1), CURV E FILE-S RT;

INSERT POINT OR CURVE;

INSERT P2 -> POINT ON CURVE;

The REMOVP. statement is used to remove a member entity from one or more sets. If. the ALL option is used, the member entity will be removed from ~11 sets of which i t is a member. If an entity is freed, i t will automatically be Lemoved from all sets of which it is a member. If a deleted entity contains one or more sets, all members of these sets will be deleted provided they are members of no other sets.

This recursive process is continued until no more entities can be deleted. Member entities will be deleted regardless of their membership in other sets if the INCLUSIVE option is applied to the FREE statement.

Chapter 6 -- File Handling 131

APPLE BEFERENCE ftANUAL

Example:

DECLARE (A, B) POINTER, ALL BUILTIN, LINE ENTITY (B), SETNAK CHAR (8) ; REMOVE LINE PROK ALL;

...

. . .

SETN!M

=

'LINE_SET';

REMOVE A -> LINE PROM SETNAM;

31 MARCH 1972

Sets may be searched using either the FIND or FOR EACH statements. The FIND statement is used to locate a particu-lar member of a set or entity that contains a set. If the search is successful, the FIND statement will set a locator-variable to reference a generation of an entity-variable.

Since sets are ordered, the FIND statement provides a means for specification of the n-th member. The user may option-ally search for an entity of a particular type. The absence of the CONTAINING option assumes the search viII be made for a member entity. If the CONTAINING option is used, the search will be made for an entity that contains the referenced set. Searches that are unsuccessful viII either raise the PIND condition or cause control to pass to an optional ELSE statement.

Conditions may be placed on the extent of the search performed by the FIND statement. The optional WITH clause allows a relational-expression to be evaluated for every entity included in the search of a set. The relational-expression may involve attributes of the current entity. If the relation is true, the entity will be counted in the search. If the relation is false, the entity will ng! be counted in the search and the search will continue. If the optional UNTIL clause is used, the search will be terminated if the UNTIL relational-eKpression is true.

132 Chapter 6 -- File Handling

31 MARCH 1972

Example:

DECLARR (P1,P2) POINTER, DATA ENTITY (P1);

FIND DATA

... =

(I) ENTITY IN 'SETAl;

. . .

FIND P2

=

(1) ENTITY CONTAINING P1 ON P2 -> 51;

If a group of statements is to be executed for all or part of the members or containers of a set, the FOR EACH statement may be used to delimit the start of the group.

The forms of the FOR EACH statement have a one to one correspondence with the forms of the PIND statement. In practice, the function of a POR EACH statement may be replaced by the corresponding FIND statement within a DO WHILE qroup. In all cases, the failure to find the next member or container of the set is sufficient cause to terminate the qroup.

Examples:

DECLARE (A ,B) POINTER, ORDER ENTITY (A);

. . .

POR EACH B -> ORDER=ENTITY ON T5ET;

I

=

I + 1;

N(I)

=

B -> ORDER. NAME;

END;

The Apple language includes a collection of 8 built-in functions to aid in the manipulation of entities and sets.

The operation of each function is described in Appendix 1 of this manual.

Chapter 6 -- File Handling 133

APPLE REFERENCE MANUAL

31 MARCH 1972

Im Dokument ::-:0==0 (Seite 132-136)