separate (Tracker.Element_Pkg)


procedure Add_Record_To_Lists (El_Record : in Element_Pointer) is
    -----------------------------------------------------------------------------
    --|  NAME:  ADD_RECORD_TO_LISTS
    --|
    --|  OVERVIEW:
    --|    This procedure is called by EL_SET_UP and EL_ADD.  It
    --|    adds the element record to every data's element list
    --|    by calling the List_Pkg procedures FINDto find the record and
    --|    return the pointer and ADD to append the record to the list.
    --|
    --|  EXCEPTIONS HANDLED:
    --|    none
    --|
    --|  HISTORY:
    --|    written by   May Lee   March 1985
    --|
    --|  NOTES:
    --|    The pointer to the current element record is passed as a parameter.
    -----------------------------------------------------------------------------
    Found : Boolean;          -- parameter to find
    El_Record2 : Element_Pointer;
    Ms_Record : Milestone_Pointer; -- to add the element to the ms_el_list
    Pr_Record : Personnel_Pointer; -- to add the element to the pr_el_list
    Ss_Record : Subsystem_Pointer; -- to add the element to the ss_el_list

begin
    -- add element to element list
    Add (El_List, El_Record.Desc_Key, El_Record);

    -- Every element has every activity, so activity doesn't
    -- have an element list.  Every other data has to have the
    -- element added to its own element list.

    -- find the correct milestone
    Find (Ms_List, El_Record.Milestone_Num, Ms_Record, Found);
    -- add element to milestone element list
    Add (Ms_Record.Element_List, El_Record.Desc_Key, El_Record);

    -- find the correct person
    if El_Record.More_Than_One_Person then
        -- add the element to the person's list, if not already added
        for Ac_Index in 1 .. Num_Of_Activities loop
            Find (Pr_List, El_Record.People_Initials (Ac_Index),
                  Pr_Record, Found);
            Find (Pr_Record.Element_List,
                  El_Record.Desc_Key, El_Record2, Found);

            if not Found then
                Add (Pr_Record.Element_List, El_Record.Desc_Key, El_Record);
            end if;
        end loop;
    else
        Find (Pr_List, El_Record.Person_Initials, Pr_Record, Found);
        Add (Pr_Record.Element_List, El_Record.Desc_Key, El_Record);
    end if;

    -- find the correct subsystem
    Find (Ss_List, El_Record.Subsystem_Name, Ss_Record, Found);
    -- add element to subsystem element list
    Add (Ss_Record.Element_List, El_Record.Desc_Key, El_Record);
end Add_Record_To_Lists;

