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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,92ac415bbb0f451b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.38.38 with SMTP id d6mr36423395pbk.4.1317342360477; Thu, 29 Sep 2011 17:26:00 -0700 (PDT) Path: lh7ni7877pbb.0!nntp.google.com!news1.google.com!postnews.google.com!d17g2000yqa.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: How to read records as strings? Date: Thu, 29 Sep 2011 17:26:00 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1fdacb1d-d67f-4f2a-8d6a-1bdedf2754a9@z19g2000vby.googlegroups.com> NNTP-Posting-Host: 24.230.151.194 Mime-Version: 1.0 X-Trace: posting.google.com 1317342360 7915 127.0.0.1 (30 Sep 2011 00:26:00 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 30 Sep 2011 00:26:00 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d17g2000yqa.googlegroups.com; posting-host=24.230.151.194; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:7.0) Gecko/20100101 Firefox/7.0,gzip(gfe) Xref: news1.google.com comp.lang.ada:18210 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-09-29T17:26:00-07:00 List-Id: On Sep 29, 3:48=A0pm, pack2themoon wrote: > Hi, everyone, I'm a beginner, and I don't have a solid understanding > of object-oriented programming. > For a homework, I need to read the following record as strings from a > file. > In the next steps, I need to know the "length" of each word to > facilitate the processing like "reverse", adding numbers...etc. > > Can I use the "length" function of bounded-string? how to use generic > package, can anyone give me the structure of the whole program(like > where to use, with =A0package, where to begin..)? Thank you so much!!! > > Alice =A0 =A0 =A0 =A0 =A00001 =A0 =A0 =A0 =A0 =A0 =A0 95 =A0 =A0 =A096 > Bob =A0 =A0 =A0 =A0 =A0 =A00002 =A0 =A0 =A0 =A0 =A0 =A0 85 =A0 =A0 =A086 > Cathy =A0 =A0 =A0 =A0 =A00003 =A0 =A0 =A0 =A0 =A0 =A0 75 =A0 =A0 =A076 > David =A0 =A0 =A0 =A0 =A00004 =A0 =A0 =A0 =A0 =A0 =A0 65 =A0 =A0 =A066 > Edward =A0 =A0 =A0 =A0 0005 =A0 =A0 =A0 =A0 =A0 =A0 85 =A0 =A0 =A086 > Frank =A0 =A0 =A0 =A0 =A00006 =A0 =A0 =A0 =A0 =A0 =A0 77 =A0 =A0 =A078 Well, it's line-delimited so read each one as a string; it will look something like this (after the appropriate file-opening, type- definitions, & assuming Ada 2005): Function Get_Record( File : In File_Type ) Return Record_Type is Use Ada.Text_IO, Ada.Strings, Ada.Strings.Fixed; Line_Value: String:=3D Trim( Get_Line(File), Both ); Marker : Positive:=3D Positive'First; Begin Return R:Record_Type do Loop -- Read from Marker to the end of the token Exit when -- the end of the token is the end of the line -- Place Marker at the correct, new position End Loop; End Return; End Get_Record;