comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: How to read records as strings?
Date: Thu, 29 Sep 2011 17:26:00 -0700 (PDT)
Date: 2011-09-29T17:26:00-07:00	[thread overview]
Message-ID: <abf35cc3-0bf7-4528-8862-e71bcf0871eb@d17g2000yqa.googlegroups.com> (raw)
In-Reply-To: 1fdacb1d-d67f-4f2a-8d6a-1bdedf2754a9@z19g2000vby.googlegroups.com

On Sep 29, 3:48 pm, pack2themoon <maxia...@gmail.com> 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  package, where to begin..)? Thank you so much!!!
>
> Alice          0001             95      96
> Bob            0002             85      86
> Cathy          0003             75      76
> David          0004             65      66
> Edward         0005             85      86
> Frank          0006             77      78

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:= Trim( Get_Line(File), Both );
   Marker : Positive:= 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;





       reply	other threads:[~2011-09-30  0:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1fdacb1d-d67f-4f2a-8d6a-1bdedf2754a9@z19g2000vby.googlegroups.com>
2011-09-30  0:26 ` Shark8 [this message]
2011-09-30  0:28 ` How to read records as strings? John B. Matthews
     [not found]   ` <d983b030-44ca-402f-a242-d31634fd7a86@j19g2000vbn.googlegroups.com>
2011-09-30  4:38     ` John B. Matthews
2011-09-30  5:43       ` Jeffrey Carter
2011-09-30 22:37         ` Randy Brukardt
2011-09-30 22:52           ` Jeffrey Carter
replies disabled

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