comp.lang.ada
 help / color / mirror / Atom feed
From: juanmiuk <juanmiuk@googlemail.com>
Subject: Re: How it works get_line function
Date: Sat, 9 May 2009 13:56:52 -0700 (PDT)
Date: 2009-05-09T13:56:52-07:00	[thread overview]
Message-ID: <5d6e1722-e83a-4c2b-9ad0-194a20ebbddf@q14g2000vbn.googlegroups.com> (raw)
In-Reply-To: hy1Nl.689923$yE1.206071@attbi_s21

Hello Jeffrey,

First of all say thank you for you help. I got it, and I wrote a
program for show you:

with Ada.Text_Io;		use Ada.Text_Io;
with Ada.Integer_Text_IO;	use Ada.Integer_Text_IO;

procedure Read_String_func_1 is

begin
	Put ("Type a String: ");
	declare
	    Cadena : Constant String := Get_Line;
	begin
		Put("You typed: " & Cadena);
	end;

	New_Line;

	Put("Type a Integer: ");
	declare
		Input : Constant String := Get_Line;
		Num   : Natural;
	begin
		Num := Natural'Value(Input);
		Put ("You typed :" );
		Put(Num, 6);
		New_Line;
		Put("Converted with Natural'Image is: " & Natural'Image(Num));
	end;

end Read_String_Func_1;
On 8 May, 22:33, "Jeffrey R. Carter"
<spam.jrcarter....@nospam.acm.org> wrote:
> juanmiuk wrote:
> > with Ada.Text_Io;
> > use Ada.Text_Io;
>
> > procedure Read_String_func is
> >    Line : String (1 .. 80);
> > begin
> >    Put("Write a string: ");
> >    Line := Get_Line;
> > end Read_String_Func;
>
> > Write a string: adfkjadfk
>
> > raised CONSTRAINT_ERROR : read_string_func.adb:11 length check failed
>
> > What I was doing wrong?
>
> You were attempting to assign a 9-Character String to an 80-Character String.
> When assigning arrays, both sides need to be the same size.
>
> The Get_Line function is best suited to initializing a String object, or
> providing a value to another subprogram:
>
> S1 : constant String := Ada.Text_IO.Get_Line;
>
> S2 : String := Ada.Text_IO.Get_Line;
>
> Ada.Text_IO.Put_Line (Item => Ada.Text_IO.Get_Line);
>
> --
> Jeff Carter
> "I like it when the support group complains that they have
> insufficient data on mean time to repair bugs in Ada software."
> Robert I. Eachus
> 91




      reply	other threads:[~2009-05-09 20:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-08 20:50 How it works get_line function juanmiuk
2009-05-08 21:33 ` Jeffrey R. Carter
2009-05-09 20:56   ` juanmiuk [this message]
replies disabled

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