From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7bbb352cbf633c73 X-Google-Attributes: gid103376,public From: johnherro@aol.com (John Herro) Subject: Re: Help with Text_IO Instantiation! Date: 1996/04/24 Message-ID: <4llqlg$i49@newsbf02.news.aol.com>#1/1 X-Deja-AN: 151217030 sender: root@newsbf02.news.aol.com references: <4lc67p$jeh@hatathli.csulb.edu> organization: America Online, Inc. (1-800-827-6364) newsgroups: comp.lang.ada Date: 1996-04-24T00:00:00+00:00 List-Id: rgelb@csulb.edu (Robert Gelb) wrote: > type string is array(integer range 1..10) of character; > type SaType is array(integer range <>) of string; > StrArray:SaType(1..5); > begin > put(StrArray(1));. > What kind of Text_IO instatiation do I need to > make 'put(StrArray(1));' work? Robert Dewar's answer is entirely correct, but allow me to add some comments. In writing type string is array(integer range 1 .. 10) of character; you're doing two potentially confusing things which beginners should avoid and even veteran programmers should do very rarely, if at all. First, you've chosen a name, string, which is *already defined* by the Ada language. In doing this, you "hide" the definition of String built into Ada, namely type String is array(Integer range <>) of Character; This is asking for confusion. You don't need to declare type String in your program because it's already defined by the language. Second, you declared a new *type* when it appears that what you want to declare is a *subtype*. Since you use your declaration only in the following line to declare SaType, I think what you meant to do was: subtype String10 is String(1 .. 10); type SaType is array(Integer range <>) of String10; Now your Put statement will work fine, with no instantiations necessary. Incidentally, it's legal to combine the above two lines into one as follows: Type SaType is array(Integer range <>) of String(1 .. 10); Also, note that Ada.Text_IO itself is not generic, but ready-to-use for the type String built into the language. Therefore, Ada.Text_IO itself needs no instantiation. Inside Ada.Text_IO are generic packages for integers, floats, enumeration types, etc. that can be instantiated with approprate user-defined types, but there's no package ready to be instantiated with a user-defined string type, because you would rarely, if ever, want to define your own string type. *Subtypes* of the built-in type String are perfectly OK, and, since subtypes do not create a new type, Ada.Text_IO works fine for them. I hope this helps, and I hope it clears up more confusion than it causes! - John Herro Software Innovations Technology http://members.aol.com/AdaTutor ftp://members.aol.com/AdaTutor