[comp.lang.ada] test program for enumeration_IO

mfeldman@seas.gwu.edu (Mike Feldman) (05/08/90)

WITH Text_IO;
PROCEDURE Colors IS
 
    TYPE English_Colors IS 
       (white, black, red, purple, blue, green, yellow, orange);
           
    TYPE French_Colors IS 
       (blanc, noir, rouge, pourpre, bleu, vert, jaune, orange);
           
    PACKAGE English_Color_IO IS 
       NEW Text_IO.Enumeration_IO (Enum => English_Colors);
 
    PACKAGE French_Color_IO IS 
       NEW Text_IO.Enumeration_IO (Enum => French_Colors);
 
    Eng_Color : English_Colors;
    Fr_Color  : French_Colors;
    Position  : Natural;
     
BEGIN
  Text_IO.Put (Item => "Please enter an English color >");
  English_Color_IO.Get (Item => Eng_Color);

  Position := English_Colors'Pos(Eng_Color);
  Fr_Color  := French_Colors'Val(Position);
   
  Text_IO.Put (Item => "The French color is ");

  -- the first line below will compile;
  -- will the second line?
  French_Color_IO.Put (Item => Fr_Color);
  French_Color_IO.Put (Item => Fr_Color, Set => Lower_Case);
  Text_IO.New_Line;
END Colors;
 

stt@inmet.inmet.com (05/08/90)

Re: Use of "SET=>LOWER_CASE" in Enumeration_IO.

LOWER_CASE is an enumeral from the type TEXT_IO.TYPE_SET.
This means that the enumeral is declared "within" TEXT_IO,
and you must either "use" TEXT_IO, or specify the
value for the "SET" parameter as "TEXT_IO.LOWER_CASE.

I.e., this should work:
    French_Color_IO.Put(Item => Fr_Color, Set => Text_IO.Lower_Case);

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138