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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7d05ebe305483c33 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-01 13:23:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: Michal Nowak Newsgroups: comp.lang.ada Subject: Re: Newbie question Date: Tue, 01 Jan 2002 22:26:37 +0100 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <3C2B2F52.2569C5E@icn.siemens.de> 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 1009920182 87011 137.194.161.2 (1 Jan 2002 21:23:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 1 Jan 2002 21:23:02 +0000 (UTC) To: "comp.lang.ada usegroup->mailing list gateway" 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.6 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:18420 Date: 2002-01-01T22:26:37+01:00 On 01-12-31 at 17:51 Jasbinder S Uppal wrote: [snip] >PS Michal hope ur feeling better, if not, a dose of Ada will certainly fix >any ailments u have..... Thank you sincerely, I'm OK now. I'm glad I've been a bit helpful. I hope that the errors I made did not confused you. I'm newbie also...My advices were a bit in C-tone, I wasn't well aware of Ada strings. I learned a bit more when I was lying in bed and reading Cohen's book. Maybe this will be more helpful than my last "advices". If you have access to Reference Manual (HTML files are installed with GNAT, so you should), look at Annex A, section 4 (particularly 4.2). There is useful package Ada.Strings.Maps and Ada.Strings.Fixed (the latter in case if you use fixed length Strings). It will be much easir to parse the input line using functions and procedures from these packages. I think that procedure Find_Token will be helpful. A token can be a sequence of characters belonging to some set. The second parameter of Find_Token is of type Character_Set. As I remember, the first word was the name of place (so it consists of upper and lowercase letters) and the second was road number (consisting of letters and numbers) and the rest was hour (only numbers). In Ada.Strings.Maps.Constants there are predefined sets of chracters: Alphanumeric_Set : ISO-8859-1 letters and numbers, Letter_Set : ISO-8859-1 letters, Decimal_Digit_Set : Decimal numbers. Alphanumeric_Set consists not only Enlish letters, but also letters with diacritical marks. This piece of code shows chracters from this set: with Ada.Strings.Maps.Constants; use Ada.Strings.Maps; --for procedures use Ada.Strings.Maps.Constants; --for constant sets with Ada.Text_IO; use Ada.Text_IO; procedure Show_Set is begin Put (To_Sequence(Alphanumeric_Set) ); end Show_Set; If you apply Find_Token to extracting values, all can be written like this: Find_Token (Input_Line, Letter_Set, Inside, From, To); In From and To variables you will get beginning and end of first word. You may than use slice operation to get the first word into string: Place := To_Unbounded_String (Input_Line (From .. To) ); (I assume here, that place is of type Unbounded_String, declared in Ada.Strings.Unbounded, you may need to "with" this package); Than you may repeat the search for the second word: Find_Token (Input_Line (To + 1 .. Input_Line'Last), Letter_Set, Inside, From, To); ^^ This To was obtained in first call to Find_Token. And then extract the second word and do the same for numbers. I hope I was more helpful now and that I was not to late. Enjoy, Mike( ----------------------------------------- ____| \%/ |~~\ O | o>> Mike Nowak | T | / > vinnie@inetia.pl | http://www.geocities.com/vinnie14pl _|__