separate (Help_Utility)
-------------------------PROLOGUE---------------------------------------
--                                                                    -*
-- Unit name    :  FIND_KEYWORD
-- Date created :  28 January 1985
-- Last update  :
--                                                                    -*
------------------------------------------------------------------------
--                                                                    -*
-- Abstract     : This procedure will return a node (list of nodes) that
----------------: potentially matches the given name. A count is returned
----------------: of the number of matches.
--                                                                    -*
------------------------------------------------------------------------
--
-- Mnemonic     :
-- Name         :
-- Release date :
------------------ Revision history ------------------------------------
--
-- DATE  AUTHOR   HISTORY
--
--
--


--------------------END-PROLOGUE----------------------------------------
procedure Find_Keyword (Node_Name : in String;
                        Node_Name_Length : in Natural;
                        Node : in Help_Utility.Help_Link;
                        Keyword_Matches : out Help_Utility.Help_Link;
                        Match_Count : in out Natural) is

    Keyword_Node : Help_Utility.Help_Link := null;
    Prev_Node : Help_Utility.Help_Link := null;
    Curr_Node : Help_Utility.Help_Link := null;
    Top : Help_Utility.Help_Link := Curr_Node;

begin

    Keyword_Node := Node.Subtopics;
    Match_Count := 0;

    -- loop through all subtopics of current level and save any potential matches

    while Keyword_Node /= null loop
        begin

            -- make the procedure call with input and subtopic name

            Help_Info_Support.Identify_Keyword
               (Node_Name, Node_Name_Length, Keyword_Node.Name);

            -- if a match is found, control returns to here, else exception is raised
            -- save the match (could be partial match)

            Curr_Node := new Help_Utility.Help_Topic;
            Curr_Node.all := Keyword_Node.all;

            if Prev_Node = null then
                Top := Curr_Node;
            else
                Prev_Node.Next_Topic := Curr_Node;
            end if;

            Prev_Node := Curr_Node;
            Match_Count := Match_Count + 1;

            -- if a match is not made then exception is raised

        exception
            when Keyword_Not_Found =>
                null;
        end;

        Keyword_Node := Keyword_Node.Next_Topic;
    end loop;

    Keyword_Matches := Top;

    -- other exceptions handled here

exception
    when others =>
        raise;
end Find_Keyword;