comp.lang.ada
 help / color / mirror / Atom feed
* Array help needed..
@ 2002-05-07 17:12 devine
  2002-05-07 17:21 ` chris.danx
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: devine @ 2002-05-07 17:12 UTC (permalink / raw)


Hi.  Kinda of a newbie to ada.  I have a array setup into which I want
to put words.  I keep getting a standard.integer error for this line:
Ada.Text_IO.Put(Item => Found(Word)), can someone please explain why I
am getting that error and how I can fix it?  I excluded the open file
code.

  Char : Character  
  Found : String(1..10) 

  TYPE CharArray IS ARRAY (1..80) of Character;
  Word : CharArray;

  LOOP
    EXIT WHEN Ada.Text_IO.End_Of_File(InData);
    LOOP
    Ada.Text_IO.Get(File => InData, Item => Char);
       IF Char IN 'a'..'z' THEN
       Ada.Text_IO.Put(Item => Found(Word));
       END IF;
    END LOOP;
  END LOOP; 

Thanks.



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

* Re: Array help needed..
  2002-05-07 17:12 Array help needed devine
@ 2002-05-07 17:21 ` chris.danx
  2002-05-07 19:36 ` Preben Randhol
  2002-05-08  1:52 ` devine
  2 siblings, 0 replies; 5+ messages in thread
From: chris.danx @ 2002-05-07 17:21 UTC (permalink / raw)



"devine" <devine@linuxmail.org> wrote in message
news:e6a474c.0205070912.49f26224@posting.google.com...
> Hi.  Kinda of a newbie to ada.  I have a array setup into which I want
> to put words.  I keep getting a standard.integer error for this line:
> Ada.Text_IO.Put(Item => Found(Word)), can someone please explain why I
> am getting that error and how I can fix it?  I excluded the open file
> code.

Found is an string of characters indexed by integers, right?  What you've
done is to try to use Word as an index which is an array of characters, not
an integer hence the message.  What are you trying to do?



Chris







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

* Re: Array help needed..
  2002-05-07 17:12 Array help needed devine
  2002-05-07 17:21 ` chris.danx
@ 2002-05-07 19:36 ` Preben Randhol
  2002-05-08  1:52 ` devine
  2 siblings, 0 replies; 5+ messages in thread
From: Preben Randhol @ 2002-05-07 19:36 UTC (permalink / raw)


On 7 May 2002 10:12:08 -0700, devine wrote:
> Hi.  Kinda of a newbie to ada.  I have a array setup into which I want
> to put words.  I keep getting a standard.integer error for this line:

You are putting characters by the look of it.

> Ada.Text_IO.Put(Item => Found(Word)), can someone please explain why I
> am getting that error and how I can fix it?  I excluded the open file
> code.

Because Word is not an integer. You have defined Found to be a
String(1..10), but Word is an array of characters. But I really don't
understand your code or what you try
to do. Is this an assignment?

Preben



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

* Re: Array help needed..
  2002-05-07 17:12 Array help needed devine
  2002-05-07 17:21 ` chris.danx
  2002-05-07 19:36 ` Preben Randhol
@ 2002-05-08  1:52 ` devine
  2002-05-08  9:39   ` David C. Hoos, Sr.
  2 siblings, 1 reply; 5+ messages in thread
From: devine @ 2002-05-08  1:52 UTC (permalink / raw)


I trying to do this.  Read a file, check to see if their are words in the
file and then put the words into an array.  So I used 'a'..'z' to get a
character so when it hits a space that would be the end of the word, it
would move to the next character after the space.





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

* Re: Array help needed..
  2002-05-08  1:52 ` devine
@ 2002-05-08  9:39   ` David C. Hoos, Sr.
  0 siblings, 0 replies; 5+ messages in thread
From: David C. Hoos, Sr. @ 2002-05-08  9:39 UTC (permalink / raw)



----- Original Message ----- 
From: "devine" <devine@linuxmail.org>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: May 07, 2002 8:52 PM
Subject: Re: Array help needed..


> I trying to do this.  Read a file, check to see if their are words in the
> file and then put the words into an array.  So I used 'a'..'z' to get a
> character so when it hits a space that would be the end of the word, it
> would move to the next character after the space.
> 
Consider these possibilities:

  1.  The words may have capital letters and apostrophes -- i.e.,
      characters that are not in 'a' .. 'z', 

  2.  The spaces between words may not just be single space characters --
      they may have multiple spaces, tabs, periods, commas, and other
      punctuation marks.

  3.  What about numbers? E.g., if you have the sentence "there were 375
      people present." -- is 375 a word?

You should loook at the procedure Ada.Strings.Fixed.Find_Token which
allows you to find tokens that include a particular group of characters,
or that exclude a particular list of characters.






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

end of thread, other threads:[~2002-05-08  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-07 17:12 Array help needed devine
2002-05-07 17:21 ` chris.danx
2002-05-07 19:36 ` Preben Randhol
2002-05-08  1:52 ` devine
2002-05-08  9:39   ` David C. Hoos, Sr.

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