with Attribute_Options, Database_Interface;
use Attribute_Options, Database_Interface;
separate (Inquiry_Operations)

--  This procedure abstracts the output function.  It uses the default
--    settings on PUT_ATTRIBUTES to print to the screen, while
--    SAVE_STATISTICS prints to a specified file.

procedure List_Statistics is
    List : Schema.Name_List;
    Name : Unit_Name_Type;
begin
    if Attribute_Options.Listing = List_By_Name then
        -- get names from user
        loop
            -- until user quits listing
            Name := Get_Unit_Name;
            Put_Attributes (Name);
            exit when not Answer ("Do you want to list another unit?");
        end loop;
    else
        -- get names from DATABASE_INTERFACE
        case Attribute_Options.Category is
            when Architecture =>
                List := Names (Schema.Architecture_Category_Type'
                               (Attribute_Options.Value));
            when E_And_V =>
                List := Names (E_And_V_Criterion_Abbreviation_Type'
                               (Attribute_Options.Value));
            when Language_Feature =>
                List := Names (Language_Feature_Abbreviation_Type'
                               (Attribute_Options.Value));
            when Statistics =>
                List := Names (Schema.Statistics_Type'
                               (Attribute_Options.Value));
            when Version =>
                List := Names (Schema.Version_Type'(Attribute_Options.Value));
            when others =>
                null;
        end case;
        Schema.First (List);
        if Empty (List) then
            Put_Line (Standard_Output, " Nothing matches that selection.");
        else
            loop
                Name := Schema.Current_Element (List);
                Put_Attributes (Name);
                exit when Schema.Tail_Node (List);
                Schema.Next (List);
            end loop;
        end if;
    end if;
exception
    when others =>
        New_Line (Standard_Output);
        Put (Standard_Output, "*** Having trouble with ");
        Put_Line (Standard_Output, Name);
end List_Statistics;
--*****************************************************************************