Re: STRING length



Thanks Georg, that looks to be exactly what I need. I do have a problem
'#including', or, 'withing' rather unbounded string.
Now the head of my source file looks like:

with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Strings.Unbounded;
use Ada.Text_IO, Ada.Integer_Text_IO;

which is alright but as soon as I try:

use Ada.Strings.Unbounded;

the compiler gives me a bunch of errors, it seems to conflict with
Text_IO / Integer_Text_IO? Seems like all my previous calls to Put()
now became invalid. I'm not familiar with Ada but with C++ and
understand namespace collisions, is the same thing going on here?

Thanks


On Nov 14, 5:24 pm, Georg Bauhaus <bauh...@xxxxxxxxxxxxx> wrote:
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.

Seehttp://en.wikibooks.org/wiki/Ada_Programming/Strings

-- Georg

.



Relevant Pages

  • Re: Dont get Array value in textbox
    ... Public Sub UT(ByVal Segment As String, ByVal BD As, ByVal ... though there's little problem with declaring it as a Function. ... USPoPA_NpaNxx = Cells(adrsX, adrsY) ... Dim test As String ...
    (microsoft.public.vb.general.discussion)
  • Re: VB 2008: Option Strict On + Infer On at class level
    ... What does the compiler prevent from declaring x As String? ... Public Sub New ...
    (microsoft.public.dotnet.languages.vb)
  • Re: problem with function
    ... Hence any attempt to write into memory past the end of oldName would ... you are declaring newName inside the ... after oldName so the compiler is not warning you when you overwrite ... If you declare a dummy string just after oldName in your second ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Working with floating point numbers.
    ... Some languages let you do this sort of thing by declaring two variables ... at the same address - e.g. a Double and an 8-byte array of Char. ... S As String * 4 ... Dim S As MyStrings ...
    (microsoft.public.access.modulesdaovba)
  • Local Variables Passing info between classes etc.
    ... which passes it the input a string at a time. ... parseArticleMethod needs to return to get the next line of input, ... Declaring a set or array etc. inside the ParseArticle ... the set or array in the superclass might work, ...
    (comp.lang.java.help)