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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7a15ffcec4cedcad X-Google-Attributes: gid103376,public From: dennison@telepath.com Subject: Re: help: String Sets in ADA??? Date: 1998/09/25 Message-ID: <6ugfd0$7tn$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 394756431 References: <360B9AFA.1F99D1CD@ios.chalmers.se> X-Http-Proxy: 1.0 x8.dejanews.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Fri Sep 25 16:12:16 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.05 [en] (WinNT; I) Date: 1998-09-25T00:00:00+00:00 List-Id: In article <360B9AFA.1F99D1CD@ios.chalmers.se>, Arash Vahidi wrote: Having troube with our homework, are we? :-) > Here is my code, but lloks like I get Cosntraint_Error as soon as I make > an assigment (see the code). ... > type Node is record > Object : String( 1..1024 ); > -- Object : String_Pointer; > Next : Node_Pointer; > end record; ... > procedure Insert( Object : in String) is > Tmp : Node_Pointer; > begin ... > First.Object := object; This line ^^^^^^^^^^^^^^^^^^^^^^^ will raise a constraint error if the string passed in to Insert isn't *exactly* 1024 characters long. You could change it to: First.Object(1..Object'length) := Object; If you want the rest of the string blanked out, you could add another line: First.Object (Object'length + 1..First.Object'last) := (others => ' '); The problem with all this is that after the call you don't have any way of finding out how many characters in a node's object contain valid data. I'd suggest looking into using the type Ada.Strings.Unbounded.Unbounded_String instead of String(1..1024). -- T.E.D. -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum