with Prompt_Pkg;

separate (Tracker)
package body Global_Pkg is
    ----------------------------------------------------------------------
    --|
    --|  NAME:  GLOBAL_PKG
    --|
    --|  OVERVIEW:
    --|    This package defines the global data and the actions that
    --|    can be performed on them.
    --|
    --|  EXCEPTIONS HANDLED:
    --|    none
    --|
    --|  HISTORY:
    --|    written by   May Lee   March 1985
    --|
    ----------------------------------------------------------------------

    use Calendar;

    procedure Gl_Initialize is
        ----------------------------------------------------------------------
        --|
        --|  NAME:  GL_INITIALIZE
        --|
        --|  OVERVIEW:
        --|    This procedure prompts for global data by calling the Prompt_Pkg
        --|    functions, which returns valid data only.
        --|
        --|  EXCEPTIONS HANDLED:
        --|    none
        --|
        --|  HISTORY:
        --|    written by   May Lee   March 1985
        --|
        ----------------------------------------------------------------------
    begin
        Project_Name := Prompt_Pkg.Project_Name;
        Project_Number := Prompt_Pkg.Project_Num;
        Manager_Name := Prompt_Pkg.Manager_Name;

        loop
            Put_Line
               (" The tracker calculations are based on the last day of a work week. ");
            Put_Line (" What is the date for this run? ");
            Date := Prompt_Pkg.Date;
            exit when Date /= Null_Date;
            Put_Line (" You cannot use a null date.  Try Again! ");
            New_Line;
        end loop;
    end Gl_Initialize;

    procedure Gl_Set_Up is
        ----------------------------------------------------------------------
        --|
        --|  NAME:  GL_SET_UP
        --|
        --|  OVERVIEW:
        --|    This procedure sets up the global variables read in from an input file.
        --|    The global data line is read in from the input file, and broken down
        --|    into the respective global variables.  The data is read in the order
        --|    specified by the GL_SAVE procedure.
        --|
        --|  EXCEPTIONS HANDLED:
        --|    others  error reading the global data
        --|    .  raises ERROR_IN_INPUT_FILE
        --|
        --|  HISTORY:
        --|    written by   May Lee   March 1985
        --|
        ----------------------------------------------------------------------
    begin
        Get (Tracker_File, Project_Name);
        Get (Tracker_File, Project_Number, Width => 3);
        Get (Tracker_File, Manager_Name);
        Get (Tracker_File, Date.Month, Width => 2);
        Get (Tracker_File, Date.Day, Width => 2);
        Get (Tracker_File, Date.Year, Width => 4);
        Get (Tracker_File, Num_Of_Activities, Width => 2);  -- integer
        Get (Tracker_File, Num_Of_Milestones, Width => 2);
        Get (Tracker_File, Num_Of_People, Width => 2);
        Get (Tracker_File, Num_Of_Subsystems, Width => 2);
        Get (Tracker_File, Num_Of_Elements, Width => 4);
        Skip_Line (Tracker_File);

        loop
            Put_Line
               (" The tracker calculations are based on the last day of a work week. ");
            Put_Line (" What is the date for this run? ");
            Date := Prompt_Pkg.Date;
            exit when Date /= Null_Date;
            Put_Line (" You cannot use a null date.  Try Again! ");
            New_Line;
        end loop;
    exception
        when others =>
            Put_Line (" Error reading global data.");
            raise Error_In_Input_File;
    end Gl_Set_Up;

    procedure Gl_Save is
        ----------------------------------------------------------------------
        --|
        --|  NAME:  GL_SAVE
        --|
        --|  OVERVIEW:
        --|    This procedure will save the global data to an output file.
        --|    The global data is composed of different types of variables.
        --|    The variables are written to the first line of the output file
        --|    in the following format:
        --||
        --||   +--------------+--------+---------------+--+--+----+--+--+--+--+----+
        --||   | project_name |proj_num| manager_name  |mo|dy| yr |ac|ms|pr|ss| el |
        --||   +--------------+--------+---------------+--+--+----+--+--+--+--+----+
        --||
        --|    See DATA_PKG for the full names and types of each variable.
        --|
        --|  EXCEPTIONS HANDLED:
        --|    none
        --|
        --|  HISTORY:
        --|    written by   May Lee   March 1985
        --|
        ----------------------------------------------------------------------

    begin
        Put (Output_File, Project_Name);
        Put (Output_File, Project_Number, Width => 3);
        Put (Output_File, Manager_Name);
        Put (Output_File, Date.Month, Width => 2);
        Put (Output_File, Date.Day, Width => 2);
        Put (Output_File, Date.Year, Width => 4);
        Put (Output_File, Num_Of_Activities, Width => 2);
        Put (Output_File, Num_Of_Milestones, Width => 2);
        Put (Output_File, Num_Of_People, Width => 2);
        Put (Output_File, Num_Of_Subsystems, Width => 2);
        Put (Output_File, Num_Of_Elements, Width => 4);
        New_Line (Output_File);
    end Gl_Save;

end Global_Pkg;