comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: Strings as Parameters
Date: Tue, 05 Oct 2004 00:41:12 GMT
Date: 2004-10-05T00:41:12+00:00	[thread overview]
Message-ID: <I4m8d.2825$UP1.2707@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <cjslbv$tb4$01$1@news.t-online.com>

Rick Santa-Cruz wrote:

> If in a subprogram I wanna use a variable of type String then I
> always have to specify, how long this String will be... for example
> the following way:

> procedure Main is
>    S: String(1..10);
> begin
>    ...
> end Main;

This is not exactly true. Every object of type String must be
constrained, but you don't always need explicit bounds.

with PragmARC.Get_Line;
procedure Martha is
    Text : String := PragmARC.Get_Line;
begin -- Martha
    ...
end Martha;

This can be very powerful in combination with block statements:

All_Input : loop
    Put (Prompt);

    One_Line : declare
       Line : String := PragmARC.Get_Line;
    begin -- One_Line
       exit All_Input when Time_To_Exit (Line);

       Process (Line);
    end One_Line;
end loop All_Input;

Every time through the loop, Line has a different value with different 
bounds.

Sometimes the block statement can be eliminated:

All_Input : loop
    Process (PragmARC.Get_Line);
end loop All_Input;

-- 
Jeff Carter
"You tiny-brained wipers of other people's bottoms!"
Monty Python & the Holy Grail
18




  parent reply	other threads:[~2004-10-05  0:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-04 23:11 Strings as Parameters Rick Santa-Cruz
2004-10-05  0:20 ` Matthew Heaney
2004-10-05  0:41 ` Jeffrey Carter [this message]
2004-10-05  1:21 ` Stephen Leake
replies disabled

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