From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,33ec76ddbb5a5c4a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How it works get_line function References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 173.16.158.68 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1241818381 173.16.158.68 (Fri, 08 May 2009 21:33:01 GMT) NNTP-Posting-Date: Fri, 08 May 2009 21:33:01 GMT Organization: AT&T ASP.att.net Date: Fri, 08 May 2009 21:33:01 GMT Xref: g2news2.google.com comp.lang.ada:5745 Date: 2009-05-08T21:33:01+00:00 List-Id: 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