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,685d80ec307a0c X-Google-Attributes: gid103376,public From: Jerry Petrey Subject: Re: use of attribute Pos Date: 2000/10/11 Message-ID: <39E4ED9F.BC361EC0@west.raytheon.com>#1/1 X-Deja-AN: 680345497 Content-Transfer-Encoding: 7bit References: <39E4A08D.B454CB1C@laas.fr> <39E4A637.AE6EE630@cepsz.unizar.es> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: news@ext.ray.com X-Trace: bos-service2.ext.raytheon.com 971304354 138.126.254.210 (Wed, 11 Oct 2000 18:45:54 EDT) Organization: Raytheon Company MIME-Version: 1.0 NNTP-Posting-Date: Wed, 11 Oct 2000 18:45:54 EDT Newsgroups: comp.lang.ada Date: 2000-10-11T00:00:00+00:00 List-Id: Alejandro Villanueva wrote: > > Philippe Torres wrote: > > > Hi, do you think the following behaviour is normal ? > > ----- > > subtype Upper is character range 'A'..'Z' ; > > begin > > Put(Upper'Pos('A')) ; > > ----- > > Output : 65 > > > > I was expecting 0 since 'A' is the first element of Upper but i got > > the ranking of 'A' in the Character type. > > > > Then you should have done this: > ----- > type Upper is new Character range 'A' .. 'Z'; > begin > Put (Upper'Pos ('A')); > end; > ----- > Output: 1 Actually this will also return the position in the base type Character or 65. > > > > What's the point of defining constrained subtype if we can't use the > > > > attributes on it ? Or am i missing something ? > > > > If you use the subtype then the correct code would be: > ----- > Put (Upper'Pos ('X') - Upper'Pos (Upper'First)); > > The above is the correct way to get what Philippe expected (with the X being replaced by A) since 'First does not apply to the base type. Jerry -- ----------------------------------------------------------------------------- -- Jerry Petrey -- Senior Principal Systems Engineer - Member Team Ada & Team Forth -- Raytheon Missile Systems -- NOTE: please remove NOSPAM in email address to reply -----------------------------------------------------------------------------