DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦620b7a063⟧ TextFile

    Length: 15003 (0x3a9b)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

separate (Help_Utility)
-------------------------PROLOGUE---------------------------------------
--                                                                    -*
-- Unit name    :  HELP_ME
-- Author       :  BASKETTE
-- Date created :  28 January 1985
-- Last update  :
--                                                                    -*
------------------------------------------------------------------------
--                                                                    -*
-- Abstract     :  This is procedure is the driver of the Help utility.
----------------: It accepts the input from the CLI and determines the
----------------: appropriate action to take.
--                                                                    -*
------------------------------------------------------------------------
--
-- Mnemonic     :
-- Name         :
-- Release date :
------------------ Revision history ------------------------------------
--
-- DATE  AUTHOR   HISTORY
--
--
--


--------------------END-PROLOGUE----------------------------------------
--with Current_Exception;
procedure Help_Me (Cli_Buffer : in String) is

    Token_Count : Positive := 1; -- number of tokens in input string
    Match_Count : Natural := 0; -- number of token matches at current level
    Counter : Natural := 0; -- loop control
    Keyword_Matches : Help_Utility.Help_Link :=
       null; -- list of nodes that match
    Top_Save : Help_Utility.Help_Link := null; -- first node of KEYWORD_MATCHES
    Same_Level : Natural := 0; -- copy of current level of node
    Msg_Name : Help_Info_Support.Help_Info_Text_Line;
    Blank_Line_Length : constant Positive := 1;
    Temp_Node : Help_Utility.Help_Link := new Help_Utility.Help_Topic;

    -- exceptions

    Help_File_Not_Read : exception;

begin

    if not Help_Utility.Initialized then
        raise Help_File_Not_Read;
    end if;

    if Help_Utility.Help_Mode then

        -- parse the input string. A table of tokens is returned

        Help_Info_Support.Parse (Cli_Buffer);

        -- if no tokens, a carriage return was entered. move up a level

        if Help_Info_Support.Number_Of_Tokens = 0 then

            -- if this is the first time help is entered and no topic is specified,
            --    output the first level memu

            if Help_Utility.First_Help_Me_Call then
                Help_Utility.Output_Line := Help_Utility.Blank_Line;
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Blank_Line, Blank_Line_Length);
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Header_Line, Help_Utility.Header_Line'Length);
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Blank_Line, Blank_Line_Length);
                Help_Utility.Print_Topic_Menu (Current_Node);

                -- else, if at the upper most level and a carriage return is entered, set
                --       terminate to true.

            else
                if Help_Utility.Current_Node = Help_Utility.Top_Node then
                    Help_Utility.Exit_Help;

                else

                    --    not at top level. back up one level (until level changes)

                    Same_Level := Help_Utility.Current_Node.Level;

                    while Help_Utility.Current_Node.Level = Same_Level loop
                        Help_Utility.Current_Node :=
                           Help_Utility.Current_Node.Parent;
                    end loop;
                end if;
            end if;

        else

            --  loop through the token table returned from PARSE until either:
            --       1) "*" found,
            --       2) "?" found,
            --       3) more than one match is found at a level or
            --       4) tokens are exhausted

            loop
                if Help_Info_Support.Input_Token_Table (Token_Count).Token
                      (1 .. Help_Info_Support.Input_Token_Table (Token_Count).
                               Length) = "*" or Help_Info_Support.Input_Token_Table (Token_Count).Token
                                                   (1 .. Help_Info_Support.Input_Token_Table (Token_Count).
                                                            Length) = "?" then
                    exit;
                end if;

                Find_Keyword
                   (Help_Info_Support.Input_Token_Table (Token_Count).Token,
                    Help_Info_Support.Input_Token_Table (Token_Count).Length,
                    Help_Utility.Current_Node, Keyword_Matches, Match_Count);

                --  if more than one (ambiguous input) or no match is found, then ignore the
                --     remaining tokens, exit loop

                if Match_Count /= 1 then
                    exit;
                end if;

                --  if all tokens checked, exit loop

                if Token_Count = Help_Info_Support.Number_Of_Tokens then
                    exit;

                else

                    --  increment the counter and update the current node to the match found

                    Token_Count := Token_Count + 1;
                    Help_Utility.Current_Node := Keyword_Matches;
                end if;
            end loop;

            -- check if all info from current level on down is requested

            if Help_Info_Support.Input_Token_Table (Token_Count).Token
                  (1 .. Help_Info_Support.Input_Token_Table (Token_Count).
                           Length) = "*" then

                Temp_Node.all := Help_Utility.Current_Node.all;
                Temp_Node.Next_Topic := null;
                Help_Utility.Display_All_Help_Info (Temp_Node);

                if Help_Utility.Current_Node.Subtopics = null then
                    Help_Utility.Current_Node :=
                       Help_Utility.Current_Node.Parent;
                end if;

                -- check if an implied help was requested, i.e., menu for current level

            elsif Help_Info_Support.Input_Token_Table (Token_Count).Token
                     (1 .. Help_Info_Support.Input_Token_Table (Token_Count).
                              Length) = "?" then
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Blank_Line, Blank_Line_Length);
                Help_Utility.Print_Topic_Text (Help_Utility.Current_Node);
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Blank_Line, Blank_Line_Length);
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Add_Header_Line,
                    Help_Utility.Add_Header_Line'Length);
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Blank_Line, Blank_Line_Length);
                Help_Utility.Print_Topic_Menu (Help_Utility.Current_Node);

                -- if a match(es) was found, output the info for that match(es)

            elsif Match_Count /= 0 then
                Counter :=
                   Match_Count;  -- counter will be used for loop control
                Top_Save :=
                   Keyword_Matches; -- save the top for later restoration

                --  this loop goes through the list (possibly only one) of matches found
                --       above. KEYWORD_MATCHES is a linked list of the matches. Each
                --       match has its text and menu of subtopics output

                while Counter /= 0 loop
                    Help_Info_Support.Append_To_Display
                       (Help_Utility.Blank_Line, Blank_Line_Length);
                    Help_Utility.Output_Line := Help_Utility.Blank_Line;
                    Help_Utility.Output_Line (1 ..
                                                 Keyword_Matches.Name_Length) :=
                       Keyword_Matches.Name (1 .. Keyword_Matches.Name_Length);
                    Help_Info_Support.Append_To_Display
                       (Help_Utility.Output_Line, Keyword_Matches.Name_Length);
                    Help_Info_Support.Append_To_Display
                       (Help_Utility.Blank_Line, Blank_Line_Length);
                    Help_Utility.Print_Topic_Text (Keyword_Matches);

                    --    check if any subtopics, i.e., if a menu should be output

                    if Keyword_Matches.Subtopics /= null then
                        if Token_Count < Help_Info_Support.Number_Of_Tokens then

                            --        this checks for the case where an ambiguous token was entered followed
                            --          by an "*". in this case, output all info for all the matches of the
                            --          ambiguous input

                            if Help_Info_Support.Input_Token_Table
                                  (Token_Count + 1).Token
                                  (1 .. Help_Info_Support.Input_Token_Table
                                           (Token_Count + 1).Length) = "*" then

                                Help_Utility.Display_All_Help_Info
                                   (Keyword_Matches.Subtopics);
                            end if;
                        else
                            Help_Info_Support.Append_To_Display
                               (Help_Utility.Blank_Line, Blank_Line_Length);
                            Help_Info_Support.Append_To_Display
                               (Help_Utility.Add_Header_Line,
                                Help_Utility.Add_Header_Line'Length);
                            Help_Info_Support.Append_To_Display
                               (Help_Utility.Blank_Line, Blank_Line_Length);
                            Help_Utility.Print_Topic_Menu (Keyword_Matches);
                        end if;
                    end if;

                    Keyword_Matches := Keyword_Matches.Next_Topic;
                    Counter := Counter - 1;
                end loop;

                --  restore the top of the list

                Keyword_Matches := Top_Save;

                --  now we must decide what the next prompt should be (and thus, what the
                --      current node should be [or vice versa]).
                --      this only matters if one and only one match was found. Else, the
                --      current node did not change.

                if Match_Count = 1 then

                    --     if there are no subtopics, the prompt should be for the next higher
                    --        level.

                    if Keyword_Matches.Subtopics = null then

                        --        if already at the highest level, set current to top

                        if Keyword_Matches.Level <= 1 then
                            Help_Utility.Current_Node := Help_Utility.Top_Node;
                        else

                            --        else, move up the links until the level changes. That node will then
                            --              become the current level

                            Same_Level := Keyword_Matches.Level;

                            while Keyword_Matches.Level = Same_Level loop
                                Keyword_Matches := Keyword_Matches.Parent;
                            end loop;

                            Help_Utility.Current_Node := Keyword_Matches;
                        end if;

                    else

                        --    if there are subtopics, the current node becomes the one found and
                        --       the user is prompted for subtopic input

                        Help_Utility.Current_Node := Keyword_Matches;
                    end if;
                end if;

            else

                --  if no match was found and not a special character (* or ?) then no info
                --     for user input request

                Help_Info_Support.Append_To_Display
                   (Help_Utility.Blank_Line, Blank_Line_Length);

                if Help_Utility.No_Doc_Line'Length +
                   Help_Info_Support.Input_Token_Table (Token_Count).Length >=
                   Help_Info_Support.Max_Line_Length then
                    Msg_Name (1 .. Help_Info_Support.Max_Line_Length) :=
                       Help_Utility.No_Doc_Line &
                          Help_Info_Support.Input_Token_Table (Token_Count).
                             Token (1 .. Help_Info_Support.Max_Line_Length -
                                            Help_Utility.No_Doc_Line'Length);

                else
                    Msg_Name (1 .. Help_Info_Support.Max_Line_Length) :=
                       Help_Utility.No_Doc_Line &
                          Help_Info_Support.Input_Token_Table (Token_Count).
                             Token (1 .. Help_Info_Support.Input_Token_Table
                                            (Token_Count).Length) &
                          (Help_Utility.No_Doc_Line'Length +
                           Help_Info_Support.Input_Token_Table (Token_Count).
                              Length + 1 ..
                              Help_Info_Support.Help_Info_Text_Line'Last =>
                              ' ');
                end if;

                Help_Info_Support.Append_To_Display
                   (Msg_Name,
                    Help_Utility.No_Doc_Line'Length +
                       Help_Info_Support.Input_Token_Table (Token_Count).
                          Length);
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Blank_Line, Blank_Line_Length);
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Add_Header_Line,
                    Help_Utility.Add_Header_Line'Length);
                Help_Info_Support.Append_To_Display
                   (Help_Utility.Blank_Line, Blank_Line_Length);

                if Help_Utility.Current_Node.Level >= 1 then
                    if Token_Count > 1 and
                       Help_Utility.Current_Node.Level /=
                          Help_Utility.Current_Node.Parent.Level then
                        Help_Utility.Current_Node :=
                           Help_Utility.Current_Node.Parent;
                    end if;
                end if;

                Help_Utility.Print_Topic_Menu (Help_Utility.Current_Node);
                Token_Count := Help_Info_Support.Number_Of_Tokens;
            end if;
        end if;

        -- before outputting the prompt, check that help was not terminated

        if Help_Utility.Help_Mode then
            Help_Utility.Print_Current_Prompt (Help_Utility.Current_Node);
        end if;

        -- indicate that HELP is active

        Help_Utility.First_Help_Me_Call := False;

    end if;

exception
    when Help_File_Not_Read =>
        raise Help_Utility.Help_File_Not_Initialized;

    when others =>
        Text_Io.Put_Line ("Help_me "); -- & Current_Exception.Name);
        Help_Utility.Help_Mode := False;
        raise;
end Help_Me;