-- Employee example, continued
-- Main routine has only two procedure calls

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

procedure employ3  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;

    procedure get(emps: out emp_array; count: out natural) is
    begin
        skip_line;

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

    procedure put(emps: emp_array; count: natural) is
        e: employee;
    begin
        -- for e of the_emps(1 .. count) loop -- ada 2012
        for i in reverse 1 .. count loop
            e := emps(i);
            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_array(1 .. 100);
    count: natural;
begin
    get(the_emps, count);
    put(the_emps, count);
end employ3;