DEFINITION MODULE ListHand;  (* LISTHAND.DEF *)

FROM Strings IMPORT CompareStr, Assign;
FROM Storage IMPORT ALLOCATE, DEALLOCATE;
FROM SYSTEM IMPORT TSIZE;
EXPORT QUALIFIED findentry, rementry, newentry, printout, do_dir, Pt;

TYPE Pt=POINTER TO idList;
     idList=RECORD
            ident:ARRAY [0..9] OF CHAR;
            legend:ARRAY [0..199] OF CHAR;
            next:Pt;
            END;

PROCEDURE findentry(ident:ARRAY OF CHAR; VAR pointer:Pt; VAR found:BOOLEAN);
(* This searches for a node that matches ident, returning the pointer to the
    previous node in pointer, with found TRUE if it is found.  If a matching
    node cannot be found, found is returned FALSE, and pointer points to the
    node to insert after.  As the nodes are kept in ident alphabetical order,
    the search terminates when it gets to a node with an ident field equal to,
    or larger than the ident searching for. *)

PROCEDURE rementry(pointer:Pt);
(* This removes the entry after the one pointed to by pointer.             *)

PROCEDURE newentry(pointer:Pt; ident,info:ARRAY OF CHAR);
(* This creates a newentry after pointer, with ident and legend as supplied. *)

PROCEDURE printout(pointer:Pt);
(* This prints out the data in the node after the one pointed to by pointer. *)

PROCEDURE do_dir;
(* This prints out a list of all the entry idents. *)

END ListHand.
