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-7-bit X-Google-Thread: 103376,6122265fe3a60a37 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-06 13:29:06 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshub2.home.com!news.home.com!news1.rdc1.mi.home.com.POSTED!not-for-mail From: "McDoobie" Subject: Re: Some problems with string type(Exact String?) Newsgroups: comp.lang.ada Organization: Caffinated Corps References: <3B1EE460.D08AD019@wanadoo.fr> <3B1E5BAA.49F1EF9B@amsjv.com> User-Agent: Pan/0.8.1beta4 (Unix) X-No-Productlinks: Yes Message-ID: Date: Wed, 06 Jun 2001 20:29:05 GMT NNTP-Posting-Host: 24.0.109.49 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.mi.home.com 991859345 24.0.109.49 (Wed, 06 Jun 2001 13:29:05 PDT) NNTP-Posting-Date: Wed, 06 Jun 2001 13:29:05 PDT Xref: archiver1.google.com comp.lang.ada:8260 Date: 2001-06-06T20:29:05+00:00 List-Id: In article <3B1E5BAA.49F1EF9B@amsjv.com>, Philip Anderson wrote: > 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.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? 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). > > >> All my greetings if you have some ideas. And forgive me for my bad >> english. > > Pas de probleme. Alright, so in this example, the string has to be EXACTLY 20 characters. Now, in a couple other languages I've used, the string can be String<20 characters but not 20