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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,e61e0c2934b7f4d5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,CP1252 Path: g2news2.google.com!postnews.google.com!d10g2000yqh.googlegroups.com!not-for-mail From: Peter Mueller Newsgroups: comp.lang.ada Subject: Re: Question on array of strings Date: Fri, 30 Oct 2009 02:10:51 -0700 (PDT) Organization: http://groups.google.com Message-ID: <24440291-27a0-4f8e-9c0c-1cecdd24af1a@d10g2000yqh.googlegroups.com> References: <562b9c59-5c4e-42d3-b4b9-bfcd33bc3211@j4g2000yqe.googlegroups.com> NNTP-Posting-Host: 91.18.55.195 Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1256893851 18676 127.0.0.1 (30 Oct 2009 09:10:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 30 Oct 2009 09:10:51 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d10g2000yqh.googlegroups.com; posting-host=91.18.55.195; posting-account=coiGjAkAAADEeVTnVGCUJXg0ieDmkuQ5 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; de-de) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8881 Date: 2009-10-30T02:10:51-07:00 List-Id: Hello, On 29 Okt., 22:38, Hibou57 (Yannick Duch=EAne) wrote: > On 29 oct, 21:48, Peter Mueller wrote: > > > > > To get a String from an access to String, you have to use the =93 .all = =94 > suffixe. > Do know what is =A0=93 .all =94 ? > If you need explanations about it, just tell, you will be asked about > it. So far I have not used ".all". > > Just change > =93 return EventStrings(Events_Type'Pos(Event)); =A0=94 > into > =93 return EventStrings(Events_Type'Pos(Event)).all; =A0=94 and every thi= ng > will be OK. > > That's to correct what does not work. Ok > > To got further now : you wants an association from Events_Type to > String, aren't you ? > So why to you use an array whose index range is =93 1 .. 2 =94 ? > I suggest you to use Events_Type instead. > > So, as a second step, you may turn > =93 eventStrings : constant array (1..2) of access constant String =94 > into > =93 eventStrings : constant array (Events_Type) of access constant > String =94 > > Do you understand what it is ? Yes, this is clear. > > Then, as you use Events_Type as the array index range, you do not need > any more (and must not also), the =93 Events_Type'Pos(Event) =94 and you > can use just Event instead > > So then replace > =93 return EventStrings(Events_Type'Pos(Event)).all =94 > with > =93 return EventStrings(Event).all =94 > > Providing that your Events_Type is a enumeration of two elements > (otherwise, just update the array initialization to match the required > number of items). > > Next now : you have an array of constant, which will be initialized > each times you enter the function. There are no kind of =93 static =94 in > Ada like there are in C. To achieve static global allocation, you have > to declare your array outside of the function, at the package level. > ... > > What tutorial do you have in hands to learn Ada ? I followed the intro from http://burks.bton.ac.uk/burks/language/ada/adacra= ft Thanks for your comprehensive answer! Peter