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,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bd4e40454c63169a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-02 15:28:08 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: Michal Nowak Newsgroups: comp.lang.ada Subject: Re: How to convert characters in a string into integers ? Date: Sun, 03 Feb 2002 00:27:56 +0100 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT X-Trace: avanie.enst.fr 1012692482 76284 137.194.161.2 (2 Feb 2002 23:28:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sat, 2 Feb 2002 23:28:02 +0000 (UTC) Return-Path: In-reply-to: X-Mailer: Calypso Version 3.20.01.01 (3) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk X-Reply-To: vinnie@inetia.pl List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:19542 Date: 2002-02-03T00:27:56+01:00 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 _|__