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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,b85c1b84f840dc22 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed101.telia.com!nf02.dk.telia.net!news.tele.dk!news.tele.dk!small.news.tele.dk!bnewspeer01.bru.ops.eu.uu.net!bnewspeer00.bru.ops.eu.uu.net!emea.uu.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: I need a little help - it's been a long time - with enumeration type and for use representation Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <7495d29e-0361-4eba-9e22-a770ae50f113@d5g2000yqm.googlegroups.com> Date: Fri, 13 Nov 2009 21:53:15 +0100 Message-ID: <1hgihvw2ld2nr.cg5ve3xaww03.dlg@40tude.net> NNTP-Posting-Date: 13 Nov 2009 21:53:16 CET NNTP-Posting-Host: 2d0d8655.newsspool3.arcor-online.net X-Trace: DXC=ZUi9S]mUh^=gP]QSEBQ^d4McF=Q^Z^V384Fo<]lROoR18kFo`eP>L5[6LHn;2LCV>[CX3?2 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8098 Date: 2009-11-13T21:53:16+01:00 List-Id: On Fri, 13 Nov 2009 13:32:52 -0700, Jeffrey R. Carter wrote: > Dmitry A. Kazakov wrote: >> On Fri, 13 Nov 2009 11:48:12 -0700, Jeffrey R. Carter wrote: >> >>> Dmitry A. Kazakov wrote: >>>> You parse "0x", then you do a hexadecimal number following it, then you >>>> pass that number (x) to: >>>> >>>> Spell_School_Type'Val (x) >>> This doesn't work with a non-default representation. 'Val reverses 'Pos, and >>> 'Pos gives sequential values starting with zero, regardless of the representation. >> >> But it works with the modular type proposed. An enumeration type was not >> meant. For enumeration types one should parse names, rather than arbitrary >> bit patterns. > > I see. I cannot imagine using 'Val in this case. Since you start with a String > containing the hexadecimal image of a value, I'd simply do > > Numeric_Type_Name'Value ("16#" & Source (Start .. Stop) & '#'); I do it differently. I have the pattern: procedure Get (Text : String; Pointer : in out Integer; Value : out Type) which I consistently deploy everywhere. Get takes a textual representation of Type from Text at Pointer and advances Pointer to the first position following it. The result is returned though Value. However, yes, usually I use a plain type conversion: Get (Text, Pointer, Integer (Value)); rather than Type'Val (when I am too lazy to instantiate the generic packages once again with Type) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de