comp.lang.ada
 help / color / mirror / Atom feed
* Help with Exceptions!
@ 1996-05-07  0:00 Robert Gelb
  1996-05-07  0:00 ` Steve Howard
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Robert Gelb @ 1996-05-07  0:00 UTC (permalink / raw)



I am doing a homework assignment in ADA and I am confused by the
exceptions.  My question is this: when I catch an error with the
exception, how can I go back to statement where the error occured (or the
statement next to it)? 
I know in Visual Basic you can do a 'resume next' statement which returns
you to the statement next to the one where the error occured

VB:
sub test()
	dim x as integer
	on error goto ErrHandler
	x = 1000000	'error occurs here
	x = 3		'resume next returns the 	
			'execution here
	Exit sub			
ErrHandler:
resume next	'return execution
end sub

ADA:
procedure test is
	x:integer;
begin
	x:=10000000;
	x:=3;
exception
	when CONSTRAINT_ERROR=>
		put("Error");
		--how can I go back to 'x:=3' statement
end test;


--
Robert Gelb
Senior Systems Analyst
Data Express
Garden Grove, California USA
(714)895-8832




^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: Help with Exceptions!
@ 1996-05-09  0:00 tmoran
  0 siblings, 0 replies; 24+ messages in thread
From: tmoran @ 1996-05-09  0:00 UTC (permalink / raw)



>In some cases, you *do* want to re-execute the same statement. For example,
>if you query the user for a number, and you get something else:
  If the user still enters 'something else' after being asked for a number
17 times, it should be clear that the prompt is not sufficiently clear,
and one might expect the next input to be the user's foot through the
screen.  The recursive solution has the advantage over a loop that it
might give a storage_error or something beforehand, thus saving the cost
of a monitor.
  Or one could abandon the 're-execute the same statement' approach for:
for p in prompt'range loop
  begin
    Put(prompt(p));
    Get ...
    return;
  exception
    when data_error =>
      if p = prompt'last then raise User_Doesnt_Get_It;end if;
  end;
end loop;
with ever more explicit and simple prompts till you give up on the user.




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

end of thread, other threads:[~1996-05-16  0:00 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-07  0:00 Help with Exceptions! Robert Gelb
1996-05-07  0:00 ` Steve Howard
1996-05-07  0:00   ` Robert Dewar
     [not found]   ` <4mqio5$a8b@news.sanders.lockheed.com>
1996-05-09  0:00     ` Robert L. Spooner, AD3K
1996-05-10  0:00   ` Jon S Anthony
1996-05-10  0:00     ` Robert A Duff
1996-05-07  0:00 ` John Herro
1996-05-07  0:00 ` Vincent Smeets
     [not found] ` <318F94D9.35AB@io.com>
1996-05-10  0:00   ` George F.Rice
1996-05-13  0:00     ` Dave Jones
1996-05-13  0:00   ` Robert I. Eachus
1996-05-14  0:00     ` John Herro
1996-05-14  0:00       ` Robert I. Eachus
1996-05-14  0:00   ` Theodore E. Dennison
1996-05-14  0:00     ` Robert A Duff
1996-05-14  0:00 ` Michel Gauthier
1996-05-14  0:00   ` Robert A Duff
1996-05-15  0:00     ` Norman H. Cohen
1996-05-15  0:00       ` Robert A Duff
1996-05-15  0:00 ` Michel Gauthier
1996-05-16  0:00 ` Jon S Anthony
1996-05-16  0:00 ` Jon S Anthony
1996-05-16  0:00   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1996-05-09  0:00 tmoran

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