-- Employee example, continued
-- Each procedure only has one parameter
-- Uses a record type to join the array and a count of the number of employees

with ada.text_io; use ada.text_io;
with ada.float_text_io; use ada.float_text_io;

procedure employ4  is
    type employee is record
        name: string(1 .. 20);
        id: string(1 .. 6);
        salary: float;
    end record;

    type emp_array is array(natural range <>) of employee;

    type emp_list is record
        emps: emp_array(1 .. 100);
        count: natural;
    end record;

    procedure get(emps: out emp_list) is
    begin
        skip_line;

        emps.count := 0;
        while not end_of_file loop
            emps.count := emps.count + 1;
            get(emps.emps(emps.count).name);
            get(emps.emps(emps.count).id);
            get(emps.emps(emps.count).salary);
        end loop;
    end get;

    procedure put(emps: emp_list) is
        e: employee;
    begin
        -- for e of the_emps(1 .. count) loop -- ada 2012
        for i in reverse 1 .. emps.count loop
            e := emps.emps(i);  -- Make a copy of the employee
            if e.salary > 50_000.00 then
                put(e.name);
                put(e.id);
                put(e.salary, 9, 2, 0);
                new_line;
            end if;
        end loop;
    end put;

    the_emps: emp_list;
begin
    get(the_emps);
    put(the_emps);
end employ4;