separate (Tracker.Personnel_Pkg.Pr_Modify)
procedure Modify_Start_Stop_Date (Pair : in Integer) is
    ----------------------------------------------------------------------------
    --|
    --|  NAME:  MODIFY_START_STOP_DATE
    --|
    --|  OVERVIEW:
    --|    This procedure is called when a pair of start/stop dates is to be
    --|    modified for a person.  The user is prompted for a new set of dates
    --|    by calling the Prompt_Pkg.date function.  The date is then compared
    --|    to others start/stop dates to see if it is valid.  If not, the user
    --|    is reprompted.  If any start/stop date is assigned a null value, the
    --|    other future start/stop dates will be modified to also be a null date
    --|    as needed.
    --|
    --|  EXCEPTIONS HANDLED:
    --|    none
    --|
    --|  HISTORY:
    --|    Written by   May Lee   March 1985
    --|    Written by   Bonnie Burkhardt   March 1985
    --|
    ----------------------------------------------------------------------------

    Valid_Start_Date : Boolean := False;

begin
    Start_Dates_Loop:
        loop
            -- get new start date
            Put (" The current start date for this set of dates is ");

            if Pr_Record.Start_Dates (Pair) = Null_Date then
                Put ("a null date. ");
            else
                Put (Pr_Record.Start_Dates (Pair).Month, 2);
                Put ('/');
                Put (Pr_Record.Start_Dates (Pair).Day, 2);
                Put ('/');
                Put (Pr_Record.Start_Dates (Pair).Year, 4);
            end if;

            New_Line;

            -- check if valid start date
            if (Pair > Dates_List'First) and then
               (Pr_Record.Stop_Dates (Pair - 1) = Null_Date) then
                Put_Line
                   (" You cannot assign a non null date to the this start ");
                Put_Line
                   (" date until you change the previous null stop date. ");
                Valid_Start_Date := False;
                delay 1.0;
                exit Start_Dates_Loop;
            end if;

            New_Line;
            Put_Line (" What would you like to change it to? ");
            Pr_Record.Start_Dates (Pair) := Prompt_Pkg.Date;

            if Pair = Dates_List'First then
                Valid_Start_Date := True;
                exit Start_Dates_Loop;
            elsif Pr_Record.Start_Dates (Pair) = Null_Date then
                for J in Pair .. Dates_List'Last loop
                    Pr_Record.Start_Dates (J) := Null_Date;
                    Pr_Record.Stop_Dates (J) := Null_Date;
                end loop;

                Valid_Start_Date := False;
                exit Start_Dates_Loop;
            elsif Pr_Record.Start_Dates (Pair) <
                  Pr_Record.Stop_Dates (Pair - 1) then
                Valid_Start_Date := False;
                New_Line;
                Put_Line
                   (" That is not a valid start date.  The start date must be ");
                Put_Line
                   (" a later date than the previous stop date.  TRY AGAIN!  ");
                Put (" The previous stop date is ");
                Put (Pr_Record.Stop_Dates (Pair - 1).Month, 2);
                Put ('/');
                Put (Pr_Record.Stop_Dates (Pair - 1).Day, 2);
                Put ('/');
                Put (Pr_Record.Stop_Dates (Pair - 1).Year, 4);
                New_Line;
            else
                Valid_Start_Date := True;
                exit Start_Dates_Loop;
            end if;
        end loop Start_Dates_Loop;

    if Valid_Start_Date then
        Stop_Dates_Loop:
            loop
                -- Get new stop date
                Put (" The current stop date for the second set of dates is ");

                if Pr_Record.Stop_Dates (Pair) = Null_Date then
                    Put ("a null date. ");
                else
                    Put (Pr_Record.Stop_Dates (Pair).Month, 2);
                    Put ('/');
                    Put (Pr_Record.Stop_Dates (Pair).Day, 2);
                    Put ('/');
                    Put (Pr_Record.Stop_Dates (Pair).Year, 4);
                end if;

                New_Line;

                -- check if valid stop date
                if (Pair > Dates_List'First) and then
                   (Pr_Record.Start_Dates (Pair) = Null_Date) then
                    Put_Line
                       (" You cannot assign a non null date to this stop ");
                    Put_Line
                       (" date until you change the previous null dates. ");
                    delay 1.0;
                    exit Stop_Dates_Loop;
                end if;

                New_Line;
                Put_Line (" What would you like to change it to? ");
                Pr_Record.Stop_Dates (Pair) := Prompt_Pkg.Date;

                if Pr_Record.Stop_Dates (Pair) = Null_Date then
                    for J in Pair + 1 .. Dates_List'Last loop
                        Pr_Record.Start_Dates (J) := Null_Date;
                        Pr_Record.Stop_Dates (J) := Null_Date;
                    end loop;

                    exit Stop_Dates_Loop;
                elsif Pr_Record.Start_Dates (Pair) = Null_Date then
                    exit Stop_Dates_Loop;
                elsif Pr_Record.Stop_Dates (Pair) <
                      Pr_Record.Start_Dates (Pair) then
                    Put_Line
                       (" That is not a valid stop date.  The stop date must be ");
                    Put_Line
                       (" a later date than the start date.  TRY AGAIN!  ");
                    Put (" The start date is ");
                    Put (Pr_Record.Start_Dates (Pair).Month, 2);
                    Put ('/');
                    Put (Pr_Record.Start_Dates (Pair).Day, 2);
                    Put ('/');
                    Put (Pr_Record.Start_Dates (Pair).Year, 4);
                    New_Line;
                elsif (Pair < Dates_List'Last) and then
                      ((Pr_Record.Start_Dates (Pair + 1) /= Null_Date) and
                       (Pr_Record.Stop_Dates (Pair) >
                        Pr_Record.Start_Dates (Pair + 1))) then
                    Put_Line
                       (" That is not a valid stop date.  The stop date must be ");
                    Put_Line
                       (" an earlier date than the next start date.  TRY AGAIN!  ");
                    Put (" The next start date is ");
                    Put (Pr_Record.Start_Dates (Pair + 1).Month, 2);
                    Put ('/');
                    Put (Pr_Record.Start_Dates (Pair + 1).Day, 2);
                    Put ('/');
                    Put (Pr_Record.Start_Dates (Pair + 1).Year, 4);
                    New_Line;
                else
                    exit Stop_Dates_Loop;
                end if;
            end loop Stop_Dates_Loop;
    end if;
end Modify_Start_Stop_Date;


