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-Language: ENGLISH,ASCII X-Google-Thread: 103376,6122265fe3a60a37 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-06 10:59:19 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!ciril.fr!univ-lille1.fr!news.cict.fr!not-for-mail From: Valdes Newsgroups: comp.lang.ada Subject: Re: Some problems with string type Date: Thu, 07 Jun 2001 06:06:02 +0200 Organization: Inconnue Message-ID: <3B1EFDAA.E2818BE9@wanadoo.fr> References: <3B1EE460.D08AD019@wanadoo.fr> <3B1E5BAA.49F1EF9B@amsjv.com> NNTP-Posting-Host: galba.edu.ups-tlse.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.cict.fr 991850356 13294 195.220.39.59 (6 Jun 2001 17:59:16 GMT) X-Complaints-To: postmaster@cict.fr NNTP-Posting-Date: 6 Jun 2001 17:59:16 GMT X-Mailer: Mozilla 4.7 [fr] (WinNT; I) X-Accept-Language: fr Xref: archiver1.google.com comp.lang.ada:8249 Date: 2001-06-06T17:59:16+00:00 List-Id: Philip Anderson a �crit : > Valdes wrote: > > > > I have my program writen in Ada that raise some exceptions: > > > > raised CONSTRAINT_ERROR : gestindex.adb:5 > > > > ... And at line 5... > > > > function createindex (S:string) return index is > > I:Index; > > begin > > i.nameindex:=s; -- Ligne cinq > > Note that Constraint Error will be raised if s is not _exactly_ 20 > characters long. I have undertood this one. It works fine now. > > > i.firstletter:=null; > > return i; > > end createindex; > > > > ... The index record is defined as follow... > > > > type index is record > > nameindex:String(1..20); > > firstletter:ptrletter; > > end record; > > > > ... The mistake seems to be trivial but I don't see it. > > > > I have seen the same for this also: > > > > Ptrtemp.Letter:=Charat(M,Ni); > > > > there is the same error but Charat return a character and letter is also > > one. (ptrtemp is also type ptrlettre) > > Is M a String and Ni an index into it? M is not exactly a string. It is a pointer to a string. I had to make this one for the first error. > If so Ni must be within the > range M'first .. M'last, and M'first may be greater than 1 (and won't be > 0). Perhaps I have better to show the function: -------------------------------------- function addwordtoindex(I :Index;M:word) return Index is ptrtemp:ptrword:=I.firstletter; aux:firstletter; J:Index; long,Ni:Natural; B:Boolean; begin long:=Lengthword(M);Ni:=1; if (ptrtemp /= Null) then while(ptrtemp /=null) loop Aux:=ptrtemp; if (ptrtemp.letter /=Charat(M,ni+1)) then ptrtemp:=ptrtemp.right; B:=false; else ptrtemp:=ptrtemp.bottom; ni:=ni+1; B:=True; end if; end loop; ptrtemp:=Aux; if (B) then ptrtemp.bottom:=new Cellword; ptrtemp:=ptrtemp.bottom; Ptrtemp.letter:=Charat(M,Ni+1); --possible exception else ptrtemp.Droite:=new Celword; ptrtemp:=ptrtemp.right; Ptrtemp.Letter:=Charat(M,Ni+1); --possible exception end if; else Ptrtemp:=new Cellword; Ptrtemp:=I.firstletter; Ptrtemp.Letter:=Charat(M,Ni); --possible exception end if; Ni:=ni+1; while(ni > > All my greetings if you have some ideas. And forgive me for my bad > > english. > > Pas de probleme. Thank you. All my greetings. > > -- > > Le Vif Z�phyr Jubile Sur Les Kumquats Du Clown Gracieux. > The quick brown fox jumps over the lazy dog. Where did you read this sentence ? On some Macintosh ? ;-)