comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: help with string splitting
Date: Thu, 09 Mar 2006 17:50:53 +0100
Date: 2006-03-09T17:50:53+01:00	[thread overview]
Message-ID: <2315080.YNFrSGcu4b@linux1.krischik.com> (raw)
In-Reply-To: 1141883649.513514.212680@p10g2000cwp.googlegroups.com

isaac2004 wrote:

> First_Half_Index  : Positive := 1;
> Second_Half_Index :  Positive := 2;
> 
> 
>>for Code_Index in Codetext'Length loop
>   >  if Code_Index <= Codetext'Length / 2 then
>  >      Plaintext(First_Half_index) := Codetext(Code_Index);
>>       First_Half_Index := First_Half_Index + 2;
>>    else
>>       Plaintext(Second_Half_Index) := Codetext(Code_Index);
>>        Second_Half_Index := Second_Half_Index + 2;
>>   end if;
>>end loop;
> 
> this code confuses me
> what is Code_Index and Codetext'Length

Code_Index is a variable declared as part of for loop. C99 can do that as
well - finally ;-) . See:

http://en.wikibooks.org/wiki/Ada_Programming/Control#for_loop

Codetext'Length is the length of the array  - mind you I would have used
Codetext'Range - which is range of valid indices for Codetext. See:

http://en.wikibooks.org/wiki/Ada_Programming/Attributes/'Length
http://en.wikibooks.org/wiki/Ada_Programming/Attributes/'Range

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



  reply	other threads:[~2006-03-09 16:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-09  0:12 help with string splitting isaac2004
2006-03-09  0:44 ` jimmaureenrogers
2006-03-09  2:21 ` Jeffrey R. Carter
2006-03-09  5:54   ` isaac2004
2006-03-09 16:50     ` Martin Krischik [this message]
2006-03-09 18:31       ` isaac2004
2006-03-09 19:58         ` jimmaureenrogers
2006-03-10 10:45         ` Martin Krischik
2006-03-09 19:28     ` Jeffrey R. Carter
2006-03-09  7:43 ` Anders Wirzenius
2006-03-09 10:15 ` Georg Bauhaus
replies disabled

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