From: Georg Bauhaus <bauhaus@futureapps.de>
Subject: Re: STRING length
Date: Tue, 14 Nov 2006 23:24:05 +0100
Date: 2006-11-15T00:21:24+01:00 [thread overview]
Message-ID: <1163543045.5361.12.camel@localhost.localdomain> (raw)
In-Reply-To: <1163544675.070347.64490@h54g2000cwb.googlegroups.com>
On Tue, 2006-11-14 at 14:51 -0800, markww wrote:
> Hi,
>
> How does one use a variable length string in ada?
You use variable length strings in Ada by declaring them
to be of type UNBOUNDED_STRING which is defined in
Ada.Strings.Unbounded.
type MY_RECORD is
record
Name: UNBOUNDED_STRING;
Phone: UNBOUNDED_STRING;
Address: UNBOUNDED_STRING;
end record;
Given that Phone is likely to be limited in length, you
could consider declaring the Phone component to be of
type BOUNDED_STRING, which is a string type with a maximum length.
Unlike STRING, objects of this type can have any number
of characters up to the maximum. See Ada.Strings.Bounded.
Yet another use of strings is in nested scopes: If you need
a string in just one place, e.g. temporarily, you can use
a plain STRING as in
declare
temp: constant STRING := some_string_returning_func(...);
begin
-- use temp
end;
The point here is that the `temp` string variable takes
its bound from the initialization. You can also make it a
variable, if you need to write to string components.
See
http://en.wikibooks.org/wiki/Ada_Programming/Strings
-- Georg
next prev parent reply other threads:[~2006-11-14 22:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-14 22:51 STRING length markww
2006-11-14 22:24 ` Georg Bauhaus [this message]
2006-11-15 0:44 ` markww
2006-11-15 1:09 ` markww
2006-11-15 1:21 ` Ludovic Brenta
2006-11-15 1:29 ` Jeffrey R. Carter
2006-11-15 2:13 ` markww
2006-11-15 1:17 ` Ludovic Brenta
2006-11-15 1:27 ` Jeffrey R. Carter
2006-11-15 16:28 ` Martin Krischik
2006-11-16 8:25 ` Jerry
-- strict thread matches above, loose matches on Subject: below --
1998-10-01 0:00 String Length mincus
1998-10-02 0:00 ` Pascal Obry
1998-10-02 0:00 ` Ehud Lamm
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox