next up previous
Next: SELECT selects messages from Up: INSTRUCTIONS Previous: REPORT allows to write

SCAN scans and processes a list of messages

Syntax:

    SCAN(<list name>, / <pointer> /) <associated instruction>;
This instruction is used to examine lists of messages to point, modify and extract messages.

<list name> is a name of an IL or EL. It may be of any node.

<pointer> is a variable declared as POINTER.

When executed, it scans the list indicated. For each scanned message the fields are passed to the O_<fields> and the <associated instruction> is executed. Then the O_<fields> are passed to the fields of the message. The scanning may be suspended when a STOPSCAN instruction is executed. Otherwise, it continues until the end of the list is reached. If a <pointer> is included, it will contain a point to the last processed message. A system generated pointer points to the previous message in the list. This allows the user to manage the pointed message.

If during the execution of the <associated instruction> a SENDTO instruction is executed the message in process is extracted and sent to the place indicated by the SENDTO. The scanning continues.

This instruction can be used in nodes of any type.

Examples:

  1.        Heating (A) Process :: IT := 10;
             SCAN(EL_Line)
              BEGIN
               O_Temp := O_Temp + UNIF(1.2, 1.3);
               IF O_Temp > 15.5 THEN SENDTO(Process);
              END;
    When Heating is activated (each 10 units of time) the EL of a node Line is scanned. A quantity (random value between 1.2 and 1.3) is added to the value of the field Temp of the message. If one message surpasses the value 15.3, it is extracted and sent to Process.
  2.     Depot (R) ::
    
        TakeHighest (A) Group ::
           H := 0; PHigh := NIL;
           SCAN(IL_Depot, Pt)
             IF O_Height > H THEN
             BEGIN PHigh := Pt; H := O_Height END;
           SCAN(EL_Group, Pg) IF O_X = 3 THEN STOPSCAN;
           IF PHigh <> NIL THEN EXTR(IL_Depot, PHigh) SENDTO(Pg, A, Group);
    When TakeHighest is activated, the message of the IL of Depot with highest value in the field Height is found and sent to the EL of Group and put after the first message with field X equal to 3.


domingo c
Mon Mar 20 17:36:19 PST 2000