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

⟦d4e2e6d8b⟧ TextFile

    Length: 8932 (0x22e4)
    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    :  INITIALIZE
-- Date created :  28 January 1985
-- Last update  :
--                                                                    -*
------------------------------------------------------------------------
--                                                                    -*
-- Abstract     :  This procedure reads in the specified help file into a
----------------: data structure (linked list). Comments are ignored. Any
----------------: input line starting with a digit is considered a new
----------------: level. All other lines are considered text lines.
--                                                                    -*
------------------------------------------------------------------------
--
-- Mnemonic     :
-- Name         :
-- Release date :
------------------ Revision history ------------------------------------
--
-- DATE  AUTHOR   HISTORY
--
--
--


--------------------END-PROLOGUE----------------------------------------
procedure Initialize (Help_File_Name : in String) is

    Previous_Node : Help_Utility.Help_Link := Top_Node;
    Previous_Line : Help_Info_Support.Text_Link := null;
    Current_Line : Help_Info_Support.Text_Link := null;
    Current_Level : Integer := 1;        -- current topic level
    Token_Is_Digits : Boolean := False;  -- indicates if new record
    First_Digit_Found : Boolean := False; -- topic must be before text
    Line_Buffer : Help_Info_Support.File_Text_Line;
    Last : Natural := 0; -- # of characters in LINE_BUFFER
    First_Text_Char : Natural := 0; -- first non-digit character

    -- exception

    Text_File_Level_Bad : exception;
    Text_Before_Topic : exception;

begin

    Help_Utility.Help_Mode := True;
    Help_Utility.First_Help_Me_Call := True;

    Text_Io.Open (Help_Utility.Help_File_Type,      -- open the help file
                  Text_Io.In_File, Help_File_Name, "");

    while not Text_Io.End_Of_File (Help_Utility.Help_File_Type) loop

        --    blank the input buffer before using

        Line_Buffer := Help_Utility.Blank_Line;

        Text_Io.Get_Line (Help_Utility.Help_File_Type, Line_Buffer, Last);

        --    Check if comment input. If so, skip the record.

        if Line_Buffer (Line_Buffer'First) = '-' and then
           Line_Buffer (Line_Buffer'First + 1) = '-' then
            null;  -- comment read, ignore it

        else

            --      Check if new topic read, i.e., digit is first character of record.

            if Line_Buffer (Line_Buffer'First) in '0' .. '9' then
                Token_Is_Digits := True;
                First_Digit_Found := True;
                First_Text_Char := 1;

                --        loop until all digits found

                while Line_Buffer (First_Text_Char) in '0' .. '9' and
                         First_Text_Char < Help_Info_Support.
                                              Max_Line_Length loop

                    First_Text_Char := First_Text_Char + 1;
                end loop;

                --        convert to integer value

                Current_Level := Integer'Value
                                    (Line_Buffer (Line_Buffer'First ..
                                                     First_Text_Char - 1)) -
                                 Integer'Value ("0");

                --        skip any blanks between level and keyword

                while Line_Buffer (First_Text_Char) = ' ' loop
                    First_Text_Char := First_Text_Char + 1;
                end loop;
            end if;

            if Token_Is_Digits then

                -- NEW TOPIC:
                --          Tree structure note: SUBTOPICS links are for children
                --                               NEXT_TOPIC links are for siblings
                --                               TOP_NODE is the Papa/Mama node
                --     Three cases:
                --     1) Current topic level is greater than previous topic level
                --          (current is subtopic of previous)
                --     2) Current topic level is less than previous topic level
                --     3) Current topic level is same as previous (or default when first)

                Previous_Line := null;
                Help_Utility.Current_Node := new Help_Utility.Help_Topic;

                if Current_Level > Previous_Node.Level then

                    --  CASE 1: Current topic level is greater than previous topic level
                    --          Set double links

                    --          check that level increases by only one

                    if Current_Level - Previous_Node.Level > 1 then
                        raise Text_File_Level_Bad;
                    end if;

                    Previous_Node.Subtopics := Help_Utility.Current_Node;
                    Help_Utility.Current_Node.Parent := Previous_Node;

                elsif Current_Level < Previous_Node.Level then

                    -- CASE 2: Current topic level is less than previous topic level
                    --         Go back up tree to same level as current.

                    while Current_Level < Previous_Node.Level loop
                        Previous_Node := Previous_Node.Parent;
                    end loop;

                    Previous_Node.Next_Topic := Help_Utility.Current_Node;
                    Help_Utility.Current_Node.Parent := Previous_Node;

                    -- CASE 3: Level has not changed.

                else

                    --          initial case only. Link off of TOP_NODE's subtopic link

                    if Previous_Node = Help_Utility.Top_Node then
                        Previous_Node.Subtopics := Help_Utility.Current_Node;
                        Help_Utility.Current_Node.Parent := Previous_Node;

                        --          all other cases when same level, link to next_topic.

                    else
                        Previous_Node.Next_Topic := Help_Utility.Current_Node;
                        Help_Utility.Current_Node.Parent := Previous_Node;
                    end if;
                end if;

                --        Save the topics name, name length, and level

                Help_Utility.Current_Node.Name
                   (1 .. Help_Info_Support.File_Text_Line'Last) :=
                   Line_Buffer (First_Text_Char .. Last) &
                      (Last - First_Text_Char + 2 ..
                          Help_Info_Support.File_Text_Line'Last => ' ');
                Help_Utility.Current_Node.Name_Length :=
                   Last - First_Text_Char + 1;
                Help_Utility.Current_Node.Level := Current_Level;

                --        update previous to current and go get next

                Previous_Node := Help_Utility.Current_Node;

                -- TEXT INPUT
                --      Add text to buffer

            elsif First_Digit_Found then

                --        get a new blank line pointer

                Current_Line := new Help_Info_Support.Text_Line;

                --        save the text

                Current_Line.Text_Line :=
                   Line_Buffer (1 .. Last) &
                      (Last + 1 .. Help_Info_Support.File_Text_Line'Last =>
                          ' ');

                --        save the length

                if Last = Natural'First then
                    Current_Line.Line_Length := Last + 1;
                else
                    Current_Line.Line_Length := Last;
                end if;

                --        update pointers. First time, link to node, otherwise link to previous

                if Previous_Line = null then
                    Help_Utility.Current_Node.Text_Lines := Current_Line;
                else
                    Previous_Line.Next_Line := Current_Line;
                end if;

                --        update the previous line

                Previous_Line := Current_Line;

            else
                raise Text_Before_Topic;

            end if;

            --       reset flag. Loop back for next

            Token_Is_Digits := False;                  -- reset flag
        end if;
    end loop;

    Text_Io.Close (Help_Utility.Help_File_Type);

    --  set top node to a level of zero. This denotes the top

    Help_Utility.Top_Node.Level := 0;
    Help_Utility.Current_Node := Top_Node;
    Help_Utility.Initialized := True;

exception
    when Text_File_Level_Bad | Text_Before_Topic =>
        raise Help_Utility.Illegal_Format_For_Help_File;

    when Text_Io.Name_Error =>
        raise Help_Utility.Help_File_Does_Not_Exist;

    when Text_Io.Status_Error | Text_Io.Use_Error =>
        raise Help_Utility.Cannot_Open_Help_File;

    when others =>
        raise;
end Initialize;