comp.lang.ada
 help / color / mirror / Atom feed
* please help me!!!!!!
@ 2001-10-18  7:33 F
  2001-10-18 11:04 ` John McCabe
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: F @ 2001-10-18  7:33 UTC (permalink / raw)


I want to "clean" the keyboard buffer after a user action, for example i
have a piece of a procedure such as
...
c:character; s:string(1..20); ind:integer:=1;
...
while not end_of_line loop
get(c);
s(i):=c;
i:=i+1;
end loop;

if a user writes "hello" and then press return i see that in my s string
there is the right information but now every time i recall the procedure the
function end_of_line starts with the true value and so the while loop is
skipped, i should try to clean the keyboard buffer after every user's press
of return.
I'm so sorry for my terrible english but i must understand in which way
solve this problem.
Thank you for your attenction
bye Phosphorus






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

* Re: please help me!!!!!!
  2001-10-18  7:33 please help me!!!!!! F
@ 2001-10-18 11:04 ` John McCabe
  2001-10-18 13:04 ` F
  2001-10-18 17:34 ` Jeffrey Carter
  2 siblings, 0 replies; 5+ messages in thread
From: John McCabe @ 2001-10-18 11:04 UTC (permalink / raw)


On Thu, 18 Oct 2001 09:33:40 +0200, "F" <phosphorus@libero.it> wrote:

Look up Ada.Text_IO.Skip_Line

>I want to "clean" the keyboard buffer after a user action, for example i
>have a piece of a procedure such as
>...
>c:character; s:string(1..20); ind:integer:=1;
>...
>while not end_of_line loop
>get(c);
>s(i):=c;
>i:=i+1;
>end loop;
>
>if a user writes "hello" and then press return i see that in my s string
>there is the right information but now every time i recall the procedure the
>function end_of_line starts with the true value and so the while loop is
>skipped, i should try to clean the keyboard buffer after every user's press
>of return.
>I'm so sorry for my terrible english but i must understand in which way
>solve this problem.
>Thank you for your attenction
>bye Phosphorus
>
>
>




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

* Re: please help me!!!!!!
  2001-10-18  7:33 please help me!!!!!! F
  2001-10-18 11:04 ` John McCabe
@ 2001-10-18 13:04 ` F
  2001-10-18 17:34 ` Jeffrey Carter
  2 siblings, 0 replies; 5+ messages in thread
From: F @ 2001-10-18 13:04 UTC (permalink / raw)



Thanks to all for your help
bye phosphorus...
F ha scritto nel messaggio <9qm0di$25sj$1@newsreader1.mclink.it>...
>I want to "clean" the keyboard buffer after a user action, for example i
>have a piece of a procedure such as
>...
>c:character; s:string(1..20); ind:integer:=1;
>...
>while not end_of_line loop
>get(c);
>s(i):=c;
>i:=i+1;
>end loop;
>
>if a user writes "hello" and then press return i see that in my s string
>there is the right information but now every time i recall the procedure
the
>function end_of_line starts with the true value and so the while loop is
>skipped, i should try to clean the keyboard buffer after every user's press
>of return.
>I'm so sorry for my terrible english but i must understand in which way
>solve this problem.
>Thank you for your attenction
>bye Phosphorus
>
>
>





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

* Re: please help me!!!!!!
  2001-10-18  7:33 please help me!!!!!! F
  2001-10-18 11:04 ` John McCabe
  2001-10-18 13:04 ` F
@ 2001-10-18 17:34 ` Jeffrey Carter
  2001-10-18 17:59   ` Jeffrey Carter
  2 siblings, 1 reply; 5+ messages in thread
From: Jeffrey Carter @ 2001-10-18 17:34 UTC (permalink / raw)


You might want to consider using a somewhat more meaningful subject.
When I see something like this, my thoughts are something like:

Somebody who calls himself F has posted a message with the subject
"please help me!!!!!!". Help is needed on what? Is it something I can
help with? Do I want to read the message and perhaps waste my time
finding out it's something I'm not interested in?

F wrote:
> 
> I want to "clean" the keyboard buffer after a user action, for example i
> have a piece of a procedure such as
> ...
> c:character; s:string(1..20); ind:integer:=1;
> ...
> while not end_of_line loop
> get(c);
> s(i):=c;
> i:=i+1;
> end loop;

It's hard to tell, since Ind is never referenced and I is undefined.
However, if I is supposed to be Ind, what you're doing is writing
Ada.Text_IO.Get_Line, except you raise Constraint_Error if the line is
as long as or longer than S, and you don't skip the line terminator if
it isn't. The easy way to do this is

Get_Line (Item => S, Last => Ind);

After this call, S (S'First .. Ind) contains the characters read. If Ind
= S'Last, then the line terminator was not skipped.

-- 
Jeffrey Carter



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

* Re: please help me!!!!!!
  2001-10-18 17:34 ` Jeffrey Carter
@ 2001-10-18 17:59   ` Jeffrey Carter
  0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey Carter @ 2001-10-18 17:59 UTC (permalink / raw)


Jeffrey Carter wrote:
> 
> F wrote:
> >
> > I want to "clean" the keyboard buffer after a user action, for example i
> > have a piece of a procedure such as
> > ...
> > c:character; s:string(1..20); ind:integer:=1;
> > ...
> > while not end_of_line loop
> > get(c);
> > s(i):=c;
> > i:=i+1;
> > end loop;
> 
> It's hard to tell, since Ind is never referenced and I is undefined.
> However, if I is supposed to be Ind, what you're doing is writing
> Ada.Text_IO.Get_Line, except you raise Constraint_Error if the line is
> as long as or longer than S, and you don't skip the line terminator if
> it isn't.

I seemed to have tripped over my tongue while typing this. This code
raises Constraint_Error if the line is longer than S; Get_Line never
raises Constraint_Error. This code never skips the line terminator;
Get_Line skips the line terminator if the line is shorter than S.

-- 
Jeffrey Carter



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

end of thread, other threads:[~2001-10-18 17:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-18  7:33 please help me!!!!!! F
2001-10-18 11:04 ` John McCabe
2001-10-18 13:04 ` F
2001-10-18 17:34 ` Jeffrey Carter
2001-10-18 17:59   ` Jeffrey Carter

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