* Raising IO_EXCEPTIONS.END_ERROR in a loop
@ 1997-11-19 0:00 Scott Ingram
1997-11-19 0:00 ` Stephen Leake
0 siblings, 1 reply; 3+ messages in thread
From: Scott Ingram @ 1997-11-19 0:00 UTC (permalink / raw)
The following fragment compiles, and even runs correctly through
one iteration but blows up when re-reading a string from standard
input. The exception that is raised makes me think that the
string variable used is still visible the second time through--
but shouldn't it pass out of existence at the end of the block?
or what am I misunderstanding?
procedure somesuch is
begin
loop
exit when Continue = 'n' or Continue = 'N';
Get_Variable:
declare
Variable_Name : String (1..OS_Line_Length);
Name_Length : Natural;
begin --Get_Variable
Put ("Enter the name of the variable to examine: ");
Get_Line (Variable_Name, Name_Length);
Put_Line ("The variable is set to " &
Variable_Name(1..Name_Length));
end Get_Variable;
Put ("Examine another (y|Y)? ");
Get_Immediate (Continue);
end loop;
end somesuch;
--
Scott Ingram
Sonar Processing and Analysis Laboratory
Johns Hopkins University Applied Physics Laboratory
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Raising IO_EXCEPTIONS.END_ERROR in a loop
1997-11-19 0:00 Raising IO_EXCEPTIONS.END_ERROR in a loop Scott Ingram
@ 1997-11-19 0:00 ` Stephen Leake
1997-11-19 0:00 ` Scott Ingram
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Leake @ 1997-11-19 0:00 UTC (permalink / raw)
Scott Ingram wrote:
>
> The following fragment compiles, and even runs correctly through
> one iteration but blows up when re-reading a string from standard
> input. The exception that is raised makes me think that the
> string variable used is still visible the second time through--
> but shouldn't it pass out of existence at the end of the block?
> or what am I misunderstanding?
> <see patched code below>
You need to be more precise about what happens - "blows up" is not
something my computer does very often :). Does it raise an exception?
crash your OS? Are you running on Windows or some other OS? You are
using Get_Immediate, which is (unfortunately), system-dependent. What
compiler are you using?
Jumping way out on a limb, I assume you have the same system I do
(Windows 95, GNAT 3.09) (yes, I'll upgrade to GNAT 3.10 one of these
days; I was holding out for an ada-aware debugger :( ). I compiled and
ran your code, after adding the missing declarations. It works fine,
except on this system Get_Immediate doesn't return until the user hits
<return>, so you need to add Skip_Line.
Hope this helps.
> --
> Scott Ingram
> Sonar Processing and Analysis Laboratory
> Johns Hopkins University Applied Physics Laboratory
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
OS_Line_Length : constant := 80;
Continue : Character := 'Y';
begin
loop
exit when Continue = 'n' or Continue = 'N';
Get_Variable:
declare
Variable_Name : String (1..OS_Line_Length);
Name_Length : Natural;
begin --Get_Variable
Put ("Enter the name of the variable to examine: ");
Get_Line (Variable_Name, Name_Length);
Put_Line ("The variable is set to " &
Variable_Name(1..Name_Length));
end Get_Variable;
Put ("Examine another (y|Y)? ");
Get_Immediate (Continue);
Skip_Line; -- added this line --
end loop;
end Test;
--
- Stephe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Raising IO_EXCEPTIONS.END_ERROR in a loop
1997-11-19 0:00 ` Stephen Leake
@ 1997-11-19 0:00 ` Scott Ingram
0 siblings, 0 replies; 3+ messages in thread
From: Scott Ingram @ 1997-11-19 0:00 UTC (permalink / raw)
Stephen Leake wrote:
>
> Scott Ingram wrote:
> >
> > The following fragment compiles, and even runs correctly through
> > one iteration but blows up when re-reading a string from standard
(extra lines snipped)
>
> You need to be more precise about what happens - "blows up" is not
> something my computer does very often :). Does it raise an exception?
> crash your OS? Are you running on Windows or some other OS? You are
> using Get_Immediate, which is (unfortunately), system-dependent. What
> compiler are you using?
>
Sorry, thought that "Raising IO_EXCEPTIONS.END_ERROR ..." as a subject
line was specific enough to elucidate how it was blowing up :-)
Also, I realize that Get_Immediate is system dependent: but I didn't
realize HOW dependent, since I have only been using in a loop as
illustrated when I wanted to hand feed some value in. Up until now,
it appeared to behave the same way (for my purposes) on several
varieties
of Unix (including Linux.)
> Jumping way out on a limb, I assume you have the same system I do
> (Windows 95, GNAT 3.09) (yes, I'll upgrade to GNAT 3.10 one of these
> days; I was holding out for an ada-aware debugger :( ). I compiled and
> ran your code, after adding the missing declarations. It works fine,
> except on this system Get_Immediate doesn't return until the user hits
> <return>, so you need to add Skip_Line.
>
> Hope this helps.
(more stuff snipped)
Yes, it does. I didn't think to try it on a sufficiently different
system
than the two where the problem showed up! Thanks.
> --
> - Stephe
--
Scott Ingram
Sonar Processing and Analysis Laboratory
Johns Hopkins University Applied Physics Laboratory
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1997-11-19 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-19 0:00 Raising IO_EXCEPTIONS.END_ERROR in a loop Scott Ingram
1997-11-19 0:00 ` Stephen Leake
1997-11-19 0:00 ` Scott Ingram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox