comp.lang.ada
 help / color / mirror / Atom feed
From: "Marc A. Criley" <mcNOSPAM@mckae.com>
Subject: Re: String
Date: Wed, 31 Aug 2005 13:11:57 -0500
Date: 2005-08-31T13:11:57-05:00	[thread overview]
Message-ID: <9dca7$4315f2f7$49953ba$30842@ALLTEL.NET> (raw)
In-Reply-To: <DWlRe.4920$qE.1125159@juliett.dax.net>

Frode Tenneb� wrote:
> On Wednesday 31 August 2005 18:52 TC wrote:
>
>>there is a function that calculate string lenght?
> 
> 'Length
>
>>how use that?
> 
> Foo : constant String := "bar";
> Len : Integer := Foo'Length; -- Len=3

This is of course correct so long as one is using fully filled-out 
string values.

(Frode, I know you know all of the following, I'm just adding to it for 
the benefit of TC :-)

Ada does not implicitly support the C approach of treating strings as an 
array of characters terminating with a null (0).  So you can't use Ada's 
strings the same way you would C's strings.

If you are going to need variable length strings, the 
Ada.Strings.Unbounded package will probably meet your needs.

If you really need C-style strings, such as when interfacing to a C 
library, you can use the Interfaces.C.Strings package.  It has a Strlen 
function that can be applied to its definition of C strings.

(Both of these packages are part of the standard Ada distribution.)

Or you can write your own package to manage strings the way that you 
want.  But given the ready availability of the above string packages, 
there's really little to be gained by doing so, unless you have some 
special needs that you have to live with, e.g., hard real-time.

-- Marc A. Criley
-- McKae Technologies
-- www.mckae.com
-- DTraq - XPath In Ada - XML EZ Out



  parent reply	other threads:[~2005-08-31 18:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-31 16:52 String TC
2005-08-31 17:38 ` String Frode Tennebø
2005-08-31 18:00   ` String Pascal Obry
2005-08-31 19:16     ` String Marin David Condic
2005-08-31 18:11   ` Marc A. Criley [this message]
2005-08-31 18:37 ` String Martin Krischik
2005-09-02 13:52 ` String Preben Randhol
  -- strict thread matches above, loose matches on Subject: below --
2003-05-31  8:55 String And838N
2003-05-31  9:38 ` String Pascal Obry
2003-05-31  9:40   ` String Pascal Obry
2003-05-31  9:39 ` String Sergey Koshcheyev
2003-06-01  3:03 ` String Jeffrey Carter
replies disabled

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