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: 103376,7776df5b2a2fcc30 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Beginner Question 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: <90ceb514-83aa-44c2-b253-218956d8426d@d17g2000yqm.googlegroups.com> Date: Thu, 21 Oct 2010 09:28:45 +0200 Message-ID: <6fnob3l0226$.2j1dfyz9j239.dlg@40tude.net> NNTP-Posting-Date: 21 Oct 2010 09:28:42 CEST NNTP-Posting-Host: b966f8d3.newsspool4.arcor-online.net X-Trace: DXC=U97C93?le:X<<0iRN7DLEQ4IUK On Wed, 20 Oct 2010 14:41:08 -0700 (PDT), SpoonThief wrote: > So, I have a question that may seem painfully obvious, but how does > one go about parsing a Float from a string that has other data in it > too? I'm getting a line from the keyboard that has a float and a > custom type in it, and I need to separate the two values. I have a set of libraries for parsing strings. This one is for integer and floating point numbers: http://www.dmitry-kazakov.de/ada/strings_edit.htm > I'm using a > call to Get_Line to get the entire line the user entered as a string, You will call Get, which takes a float number at the current string position and then advances the position pointer behind the number. [ For dimensioned floating point number parsing see: http://www.dmitry-kazakov.de/ada/units.htm ] > and when I try to call Float'Value (In_String (1 .. Last)), I get a > constraint error. Is there any way to parse a float and a custom > subtype (Excellent, Good, Fair, Poor) from one string, or am I going > about this the entirely wrong way? http://www.dmitry-kazakov.de/ada/tables.htm It pursues the same principle. You have a table of tokens (mapping of texts to some type). The table has the operation Get, which matches the string at the current position, finds the longest match, returns the corresponding value and advances the position pointer. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de