comp.lang.ada
 help / color / mirror / Atom feed
From: Michal Nowak <vinnie@inetia.pl>
Subject: Re: How to convert characters in a string into integers ?
Date: Sun, 03 Feb 2002 00:27:56 +0100
Date: 2002-02-03T00:27:56+01:00	[thread overview]
Message-ID: <mailman.1012692482.11946.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: <a3hng6$jpp$1@paris.btinternet.com>

On 02-02-02 at 21:59 Jim wrote:

>is this possible, if so how ?
>
>say im reading a string (1 + 2 + 3)    (yep carrying on with my calculator
>program :-))
>
>how to get 1 and the convert to integer, then get + and store as
character,
>get 2 and convert to integer etc ?

Have a look a Find_Token procedure (LRM A.4.3 - A.4.5). 

Little example:

Find_Token (Source => "(102 + 200 + 32)",
            Set=>To_Set("0123456789"),
            Test=>Inside,
            First,
            Last,);

This will give you the beginning and ending of first integer
in source string. You may than slice it and convert this slice
to integer:
Operand := Integer'Value (Input_String (First .. Last) );
For this case you will have 102 in Operand.

Hope this was a bit helpful,
Mike

PS. To make this code compile you will have to "with" some
packeges - look at mentioned LRM sections to which ones.
-----------------------------------------
                             ____|
                             \%/ |~~\
  O                                  |
 o>>        Mike Nowak               |
 T                                   |
/ >       vinnie@inetia.pl           |
http://www.geocities.com/vinnie14pl _|__




  parent reply	other threads:[~2002-02-02 23:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-02 21:59 How to convert characters in a string into integers ? Jim
2002-02-02 22:09 ` Florian Weimer
2002-02-02 23:27 ` Michal Nowak [this message]
2002-02-02 23:57   ` Jim
2002-02-03  3:25     ` Jim Rogers
2002-02-03  8:56     ` Michal Nowak
2002-02-04 16:12       ` Marin David Condic
2002-02-05  1:40         ` ARM (was: Re: How to convert characters in a string into integers ?) Jeffrey Carter
2002-02-05 14:57           ` Marin David Condic
2002-02-06 15:19             ` Ted Dennison
2002-02-06 15:52             ` Stephen Leake
2002-02-06 16:13             ` Jeffrey Carter
2002-02-10 16:47           ` Florian Weimer
2002-02-10 17:24             ` ARM (was: Re: How to convert characters in a string intointegers ?) Uckfay Ouyay
2002-02-05 14:36         ` How to convert characters in a string into integers ? Michal Nowak
2002-02-05 15:17           ` Jerry Petrey
2002-02-05 16:06             ` Marin David Condic
2002-02-14 19:52               ` ARM vs. LRM vs. ... (was: Re: How to convert characters in a string into integers ?) Tucker Taft
2002-02-14 20:12                 ` Jerry Petrey
2002-02-15  9:56                   ` Steffen Huber
2002-02-12 12:03 ` How to convert characters in a string into integers ? John English
  -- strict thread matches above, loose matches on Subject: below --
2002-02-06  6:55 Christoph Grein
2002-02-06  9:20 ` Jean-Etienne Doucet
2002-02-06 10:01 Christoph Grein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox