comp.lang.ada
 help / color / mirror / Atom feed
* Trouble with loop in Ada
@ 2013-01-04  4:32 Derek Wyss
  2013-01-04 10:59 ` Brian Drummond
  2013-01-04 12:44 ` Paul Colin Gloster
  0 siblings, 2 replies; 6+ messages in thread
From: Derek Wyss @ 2013-01-04  4:32 UTC (permalink / raw)


Hello,

I'm new to Ada and I'm trying to write a toy unix command shell just to 
explore the programming language.  So far I have a very small program, 
but I am confused about its behavior.

If I comment line number 11, with the Put procedure, the program loops 
through as I would expect.  However, with that line in the program, I 
have to manually press enter twice before I enter the loop.  Similarly, I 
have to hit enter one more time after the character I enter is displayed 
in order for the program to loop again.

Can anyone offer an explanation as to why I need to press enter?  I 
suspect it has to do with my use of End_Of_File and the way it "looks 
ahead" but I'm not really sure.

I'm running Linux Mint Debian Edition with the 3.2.0-4-686-pae kernel.  
I'm also using gnat, the Gnu Ada Compiler, version 4.6.  When I compile, 
I type at the command prompt:

gnatmake -gnato -fstack-check -gnatE toy_shell.adb

1  with Ada.Text_IO;
2  use Ada.Text_IO;
3
4  procedure toy_shell is
5
6    input_char: Character;
7
8  begin
9
10   while not (End_Of_File) loop
11     Put("Enter a character> ");
12     Get(input_char);
13     Put("you entered: " & input_char);
14     New_line;
15   end loop;
16
17 end toy_shell;

I hope that is enough info.  Any help would be greatly appreciated

Thanks,

Derek



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

end of thread, other threads:[~2013-01-05  5:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-04  4:32 Trouble with loop in Ada Derek Wyss
2013-01-04 10:59 ` Brian Drummond
2013-01-04 11:11   ` Brian Drummond
2013-01-04 12:44 ` Paul Colin Gloster
2013-01-04 21:27   ` Derek Wyss
2013-01-05  5:33     ` Randy Brukardt

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