comp.lang.ada
 help / color / mirror / Atom feed
* Re: How to read records as strings?
       [not found] <1fdacb1d-d67f-4f2a-8d6a-1bdedf2754a9@z19g2000vby.googlegroups.com>
@ 2011-09-30  0:26 ` Shark8
  2011-09-30  0:28 ` John B. Matthews
  1 sibling, 0 replies; 6+ messages in thread
From: Shark8 @ 2011-09-30  0:26 UTC (permalink / raw)


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;





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to read records as strings?
       [not found] <1fdacb1d-d67f-4f2a-8d6a-1bdedf2754a9@z19g2000vby.googlegroups.com>
  2011-09-30  0:26 ` How to read records as strings? Shark8
@ 2011-09-30  0:28 ` John B. Matthews
       [not found]   ` <d983b030-44ca-402f-a242-d31634fd7a86@j19g2000vbn.googlegroups.com>
  1 sibling, 1 reply; 6+ messages in thread
From: John B. Matthews @ 2011-09-30  0:28 UTC (permalink / raw)


In article 
<1fdacb1d-d67f-4f2a-8d6a-1bdedf2754a9@z19g2000vby.googlegroups.com>,
 pack2themoon <maxiang4@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

As this is homework, your instructor and textbook may have some specific 
things that you should already know and apply to solve this problem. I 
always start by creating a Short, Self Contained, Correct (Compilable), 
Example [1]. You might study these file I/O examples [2] and post your 
own SSCCE here for more comments and guidance.

Out of curiosity, what text are you using?

[1]<http://sscce.org/>
[2]<http://rosettacode.org/wiki/File_IO#Ada>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to read records as strings?
       [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
  0 siblings, 1 reply; 6+ messages in thread
From: John B. Matthews @ 2011-09-30  4:38 UTC (permalink / raw)


In article 
<d983b030-44ca-402f-a242-d31634fd7a86@j19g2000vbn.googlegroups.com>,
 pack2themoon <maxiang4@gmail.com> wrote:

> hi thanks. I already studied that page and a lot more but still have 
> no clue.
> 
> sscce is a good idea thanks.
> 
> our professor recommend <Programming in Ada 2005> by John Barnes, but 
> since it's too expensive and couldn't be found in any library nearby, 
> I am not reading any books, just check wiki or other references 
> online. It's so hard I am considering to buy the book anyway. Any 
> good suggestions?

Yes, the "Ada Programming" wiki [1] is exemplary, and "Ada 95: The Craft 
of Object-Oriented Programming" [2] is available on line. The "Rationale
for Ada 2005" [3], also by Barnes, limns the high quality of the book. 

The best way to learn is by doing; Shark8's nearby outline is a good 
starting point. Also, don't top-post, and please trim signatures when 
replying.

[1]<http://en.wikibooks.org/wiki/Ada_Programming>
[2]<http://www.cmis.brighton.ac.uk/%7Eje/adacraft/>
[3]<http://www.adaic.org/resources/add_content/standards/05rat/html/Rat-T
TL.html>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to read records as strings?
  2011-09-30  4:38     ` John B. Matthews
@ 2011-09-30  5:43       ` Jeffrey Carter
  2011-09-30 22:37         ` Randy Brukardt
  0 siblings, 1 reply; 6+ messages in thread
From: Jeffrey Carter @ 2011-09-30  5:43 UTC (permalink / raw)


On 09/29/2011 09:38 PM, John B. Matthews wrote:
>
> Yes, the "Ada Programming" wiki [1] is exemplary, and "Ada 95: The Craft
> of Object-Oriented Programming" [2] is available on line. The "Rationale
> for Ada 2005" [3], also by Barnes, limns the high quality of the book.

If you're already familiar with another programming language, /Ada Distilled/ 
can be useful:

http://www.adapower.com/pdfs/AdaDistilled07-27-2003.pdf

-- 
Jeff Carter
"C++ is like jamming a helicopter inside a Miata
and expecting some sort of improvement."
Drew Olbrich
51



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to read records as strings?
  2011-09-30  5:43       ` Jeffrey Carter
@ 2011-09-30 22:37         ` Randy Brukardt
  2011-09-30 22:52           ` Jeffrey Carter
  0 siblings, 1 reply; 6+ messages in thread
From: Randy Brukardt @ 2011-09-30 22:37 UTC (permalink / raw)


"Jeffrey Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message 
news:j63l9t$2cv$1@tornado.tornevall.net...
> On 09/29/2011 09:38 PM, John B. Matthews wrote:
>>
>> Yes, the "Ada Programming" wiki [1] is exemplary, and "Ada 95: The Craft
>> of Object-Oriented Programming" [2] is available on line. The "Rationale
>> for Ada 2005" [3], also by Barnes, limns the high quality of the book.
>
> If you're already familiar with another programming language, /Ada 
> Distilled/ can be useful:
>
> http://www.adapower.com/pdfs/AdaDistilled07-27-2003.pdf

That's a pretty old version. Find a much more recent version (2009) at 
http://www.adaic.org/learn/materials/; look under Ada 95 books.

I have an 2011 version stored in the old (dead) AdaIC website, but for some 
reason that never made it to AdaIC.org. I'll check on that ASAP...

                                 Randy.







^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to read records as strings?
  2011-09-30 22:37         ` Randy Brukardt
@ 2011-09-30 22:52           ` Jeffrey Carter
  0 siblings, 0 replies; 6+ messages in thread
From: Jeffrey Carter @ 2011-09-30 22:52 UTC (permalink / raw)


On 09/30/2011 03:37 PM, Randy Brukardt wrote:
>
> That's a pretty old version. Find a much more recent version (2009) at
> http://www.adaic.org/learn/materials/; look under Ada 95 books.
>
> I have an 2011 version stored in the old (dead) AdaIC website, but for some
> reason that never made it to AdaIC.org. I'll check on that ASAP...

Thanks for that. I'll update my bookmark.

-- 
Jeff Carter
"I would never want to belong to any club that
would have someone like me for a member."
Annie Hall
41



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-30 22:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1fdacb1d-d67f-4f2a-8d6a-1bdedf2754a9@z19g2000vby.googlegroups.com>
2011-09-30  0:26 ` How to read records as strings? Shark8
2011-09-30  0:28 ` 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

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