comp.lang.ada
 help / color / mirror / Atom feed
From: d96andgi@dtek.chalmers.se (Anders Gidenstam)
Subject: Re: Get_Line vs Adasockets
Date: 2000/08/14
Date: 2000-08-14T11:01:23+00:00	[thread overview]
Message-ID: <fki8n8.5t.ln@aragorn.hemma.kungalv.se> (raw)
In-Reply-To: 8n6cbc$9ge$1@news.tpi.pl

In article <8n6cbc$9ge$1@news.tpi.pl>,
	"Ultor" <ultor@hert.org> writes:
>Hello
>
>I'm new in ADA (code since Friday). I got a problem with Get_Line in my
>source. I tried to make it working over 2 hours and still got a problem with
>that.
>
>When i did Get_Line like this
>
>   BUF := Get_Line(Incoming_Socket);
>
>then I had problem with CONSTRAINT_ERROR. I don't know how to set size of
>BUF to be the same as line from Get_Line (as I know that should eliminate
>CONSTRAINT_ERROR).

Hello!

Well, that statement will only work if BUF and the string Get_Line returns both
have the same length...
One way to solve this problem is to use a declare-block, ie not declaring BUF
until you know how large it needs to be:

declare
  BUF : String := Get_Line(Incoming_Socket);
begin
  -- Do stuff that uses BUF.

end;

Another way is to process the data in a procedure or function:

procedure Do_Stuff (BUF : String) is ...

And in your program you call it with Get_Line as a parameter:

...
Do_Stuff (BUF => Get_Line (Incoming_Socket));
...

Regards
Anders
-- 
"A well-written program is its own heaven; 
 a poorly-written program is its own hell."
  - The Tao of Programming 





  parent reply	other threads:[~2000-08-14  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-13  0:00 Get_Line vs Adasockets Ultor
2000-08-13  0:00 ` Dale Stanbrough
2000-08-14  0:00   ` Martin Dowie
2000-08-17  0:00     ` tmoran
2000-08-21  0:00       ` Martin Dowie
2000-08-14  0:00 ` Anders Gidenstam [this message]
2000-08-14  0:00 ` Ken Garlington
2000-08-14  0:00   ` Ultor
2000-08-14  0:00     ` Ted Dennison
2000-08-14  0:00       ` Michal Zalewski
2000-08-14  0:00         ` Ted Dennison
2000-08-21  1:44   ` David Thompson
replies disabled

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