Library: OBJECT/SAMPLE/LIBRARY

The following ALGOL library, compiled as OBJECT/SAMPLE/LIBRARY, provides its entry points directly:

BEGIN
   ARRAY MSG[0:120];
   INTEGER PROCEDURE FACT(N);
   INTEGER N;
      BEGIN
      IF N LSS 1 THEN
         FACT := 1
      ELSE
         FACT := N * FACT(N - 1);
      END;  % OF FACT
   PROCEDURE DATEANDTIME(TOARRAY,WHERE);
   ARRAY TOARRAY[*];
   INTEGER WHERE;
      BEGIN
      REAL T;
      POINTER PTR;
      T := TIME(7);
      PTR := POINTER(TOARRAY,8) + WHERE;
      CASE T.[5:6] OF
         BEGIN
         0: REPLACE PTR:PTR BY "SUNDAY, ";
         1: REPLACE PTR:PTR BY "MONDAY, ";
         2: REPLACE PTR:PTR BY "TUESDAY, ";
         3: REPLACE PTR:PTR BY "WEDNESDAY, ";
         4: REPLACE PTR:PTR BY "THURSDAY, ";
         5: REPLACE PTR:PTR BY "FRIDAY, ";
         6: REPLACE PTR:PTR BY "SATURDAY, ";
         END;
      REPLACE PTR BY T.[35:6] FOR 2 DIGITS, "-",
                     T.[29:6] FOR 2 DIGITS, "-",
                     T.[47:12] FOR 4 DIGITS, ", ",
                     T.[23:6] FOR 2 DIGITS, ":",
                     T.[17:6] FOR 2 DIGITS, ":",
                     T.[11:6] FOR 2 DIGITS;
      END; % OF DATEANDTIME
   EXPORT FACT,DATEANDTIME AS "DAYTIME";
   REPLACE POINTER(MSG,8) BY
      "  - SAMPLE LIBRARY STARTED",
      " " FOR 94;
   DATEANDTIME(MSG,60);
   DISPLAY(MSG);
   FREEZE(TEMPORARY);
   REPLACE POINTER(MSG,8)+19 BY "ENDED  ";
   DATEANDTIME(MSG,60);
   DISPLAY(MSG);
END.

In this library program, two procedures are exported, making them entry points that can be called by calling programs. The two procedures, FACT and DATEANDTIME, are contained within the library program, so they are provided directly.

In the EXPORT declaration, the procedure DATEANDTIME is given the name DAYTIME in an AS clause. In the directory built for this library, the name of this entry point will be DAYTIME. Calling programs must use the name DAYTIME to call this entry point.