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: 103376,cc65ab136f46904d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!weretis.net!feeder4.news.weretis.net!news.tornevall.net!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: GNAT.Serial_Communications Date: Fri, 15 Apr 2011 11:01:33 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <9af0087d-9637-40d9-8c30-2e06c2d1e4f4@o26g2000vby.googlegroups.com> NNTP-Posting-Host: 385ddaaffdfeda0203ab65d57b6024f8 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: bfe87af705eb4720c046beb1486e2506 X-Complaints-To: abuse@tornevall.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: X-UserIDNumber: 1738 X-Validate-Post: http://news.tornevall.net/validate.php?trace=bfe87af705eb4720c046beb1486e2506 X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: g2news2.google.com comp.lang.ada:19774 Date: 2011-04-15T11:01:33-07:00 List-Id: On 04/15/2011 09:32 AM, tonyg wrote: > for count in > 1..Ada.Streams.Stream_Element_Offset(The_String'Length) loop > Return_Value(count) := > character'pos(The_String(Integer(count))); You assume that The_String'First = 1, which will not be the case if you pass a slice with a different lower bound. However, that will cause Constraint_Error (unless you have turned off this check), which does not seem to be the problem. > Return Return_Value(1..The_String'Length); I see no reason for the slice. You should be able to replace the body of String_To_Stream with a simple Unchecked_Conversion: with Ada.Streams; with Ada.Text_IO; with Ada.Unchecked_Conversion; procedure Stream_Convert is subtype String3 is String (1 .. 3); From : constant String3 := "abc"; subtype Stream3 is Ada.Streams.Stream_Element_Array (1 .. From'Length); function To_Stream is new Ada.Unchecked_Conversion (Source => String3, Target => Stream3); To : Stream3; begin -- Stream_Convert To := To_Stream (From); Output : for I in To'range loop Ada.Text_IO.Put (Item => To (I)'Img); end loop Output; end Stream_Convert; -- Jeff Carter "Unix and C are the ultimate computer viruses." Richard Gabriel 99