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: 2001-12-24 12:02:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!213.56.195.71!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: Mon, 24 Dec 2001 21:06:02 +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 1009224122 43869 137.194.161.2 (24 Dec 2001 20:02:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 24 Dec 2001 20:02: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:18284 Date: 2001-12-24T21:06:02+01:00 On 01-12-24 at 13:52 Jasbinder S Uppal wrote: >Hi, I've been subscribed to this news group for a long time (ok, when I >first started using Ada, about 2 months ago!), but this is the first time >I've actually had problems with the language and well, I was wondering if >you guys can help me. Welcome newbie, from another newbie :-)) >I've got this assignment for university that I have to do, and I am having >problems with the first bit (Not a good sign, is it....). >I've got a data file, which contains a line of data for a vehicle, and on >the line, it gives a place name, a registration number, and the time that >the car goes onto a motorway. A typical line is as follows.... > >Barnsley A123 22 15 40 >.... >.... >Where Barnsley is the place, A123 is the Registration number, and 22 15 >40 is the time (22:15:40). I've managed to get the Place name (using >characters) and the registration number (using Strings), and putting it >into >a record, but I am unsure as to what to use for the time. I could (I think) >use characters, but I need to manipulate the times later on in the program >(which could be done by having the time as an integer), but because there >are blanks in between the numbers, I am unsure as to how I can do this. >Help >me please.... > >I appreciate any help given. > >Thanks. As I said, I'm newbie also, but maybe this will be helpful. Generally speaking, you may do like this: ... Read place name, Read registration number, skip spaces, read hour, skip spaces, read minute, skip spces, read second. ... However, reading character after character from disc file is inefficient way. My proposal is to read whole line into a string. I assume, that hours, minutes and seconds are two digits numbers (so the hour 7AM is presented as 07). If no, you will have a bit more work. Extract place name from string Extract registration number Skip Spaces You should know on which position in the string you are after skipping spaces. Let's call it Current_Position and let Whole_Line be of type String and consist line from input file. Hour := Integer'Value (Whole_Line(Current_Position .. Current'Position + 2) ); Hour is of type Integer. It does not has to be predefined Integer. You may do something like this: type Hour_Type is range 0 .. 23; --this is declaration of --integer type Hour : Hour_Type; However, if you declare Hour_Type as a distinct type, you will have to cast result of Integer'Value to Hour_Type before assigning it to Hour: Hour := Hour_Type (Integer'Value ( Whole_Line(Current_Position .. Current'Position + 2) ) ); Do the same for minutes and seconds. Exception handling is your task to do. I'm not sure if this is very elegant way of doing it, but as I said, I'm still a newbie. I hope this will help you in some way. Happy Ada programming, -Mike ----------------------------------------- ____| \%/ |~~\ O | o>> Mike Nowak | T | / > vinnie@inetia.pl | http://www.geocities.com/vinnie14pl _|__