comp.lang.ada
 help / color / mirror / Atom feed
From: Peter Mueller <peter.o.mueller@gmx.de>
Subject: Re: Question on array of strings
Date: Fri, 30 Oct 2009 02:10:51 -0700 (PDT)
Date: 2009-10-30T02:10:51-07:00	[thread overview]
Message-ID: <24440291-27a0-4f8e-9c0c-1cecdd24af1a@d10g2000yqh.googlegroups.com> (raw)
In-Reply-To: 562b9c59-5c4e-42d3-b4b9-bfcd33bc3211@j4g2000yqe.googlegroups.com

Hello,

On 29 Okt., 22:38, Hibou57 (Yannick Duchêne)
<yannick_duch...@yahoo.fr> wrote:
> On 29 oct, 21:48, Peter Mueller <peter.o.muel...@gmx.de> wrote:
>
>
>

>
> To get a String from an access to String, you have to use the “ .all ”
> suffixe.
> Do know what is  “ .all ” ?
> If you need explanations about it, just tell, you will be asked about
> it.

So far I have not used ".all".

>
> Just change
> “ return EventStrings(Events_Type'Pos(Event));  ”
> into
> “ return EventStrings(Events_Type'Pos(Event)).all;  ” and every thing
> 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 “ 1 .. 2 ” ?
> I suggest you to use Events_Type instead.
>
> So, as a second step, you may turn
> “ eventStrings : constant array (1..2) of access constant String ”
> into
> “ eventStrings : constant array (Events_Type) of access constant
> String ”
>
> 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 “ Events_Type'Pos(Event) ” and you
> can use just Event instead
>
> So then replace
> “ return EventStrings(Events_Type'Pos(Event)).all ”
> with
> “ return EventStrings(Event).all ”
>
> 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 “ static ” 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/adacraft

Thanks for your comprehensive answer!

Peter



  parent reply	other threads:[~2009-10-30  9:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-29 20:48 Question on array of strings Peter Mueller
2009-10-29 21:36 ` Jeffrey R. Carter
2009-10-29 21:42   ` Hibou57 (Yannick Duchêne)
2009-10-29 22:58     ` Jeffrey R. Carter
2009-10-29 21:38 ` Hibou57 (Yannick Duchêne)
2009-10-30  0:12   ` Robert A Duff
2009-10-30  9:10   ` Peter Mueller [this message]
2009-10-30 10:14     ` Hibou57 (Yannick Duchêne)
2009-10-29 22:46 ` Gautier write-only
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox