[comp.sys.atari.8bit] Error Checking in Action!

appelbau@topaz.rutgers.edu (Marc L. Appelbaum) (07/10/87)

Does anybody have any experience with error checking in Action!?  What
I would like to do is have something similar to a BASIC trap.
Here's a simplified version of my program:

proc getfile (byte array name)
printe("File to read-->")
inputS(name)
return

prom main()
;;varios declatarions, etc
byte array fname
getfile(fname)
;;;other stuff

return

I would to have a error proc that when it finds a error 170 (invalid
file name) or device error it will ask for a new name to be entered.

Any ideas??????



	
-- 
 -Marc L. Appelbaum 				
 Arpa:appelbau@topaz.rutgers.edu                 
 Uucp:{ames, cbosgd, harvard, moss, seismo}!rutgers!topaz.rutgers.edu!appelbau
 Bitnet:appelbaum@zodiac.bitnet
 GEnie:M.APPELBAUM

mark@lakesys.UUCP (Mark Storin) (07/13/87)

In article <13254@topaz.rutgers.edu> appelbau@topaz.rutgers.edu (Marc L. Appelbaum) writes:
>
>Does anybody have any experience with error checking in Action!?  What
>I would like to do is have something similar to a BASIC trap.
>Here's a simplified version of my program:
>
>proc getfile (byte array name)
>printe("File to read-->")
>inputS(name)
>return
>
>prom main()
>;;varios declatarions, etc
>byte array fname
>getfile(fname)
>;;;other stuff
>
>return
>
>I would to have a error proc that when it finds a error 170 (invalid
>file name) or device error it will ask for a new name to be entered.
>
>Any ideas??????

	ACTION! has a built in error routine that can be redirected.  In your
case the simplest method to check for an I/O error is to create a procedure
that is called Myerr (or any such thing).  All this needs to do is to set a
global variable to the error number when called, as in:

	Proc Myerr(Byte err)
	  Errnum=err          ;Errnum being the global error variable
	Return

	In your "main" procedure add the following code:

	Card OSERR
	OSERR=Error		;save pointer to OS error routines
	Error=Myerr		;Point the error trapping at our routine

	Now, after the user inputs a file name, try to do an open on it, then
check your Errnum variable.  If it's not 0 then there has been an error and
you can check it and procede from there.

	Be sure to reset Error (Error=OSERR) before exiting the program or
else ACTION! won't be able to find its own error handlers.

------------------------------------------------------------------------------
Mark A. Storin					These opinions are my own,
Lake Systems, Milw., WI				you can't have them.
UUCP:  {ihnp4,uwvax}!uwmcsd1!lakesys!mark

sullivan@marge.math.binghamton.edu (fred sullivan) (07/13/87)

You can redefine the Action! error routine to do whatever you want
it to do.  (Including just ignore errors.)  You may need to know
how to get status for an IOCB to find out what error occurred.  There
is an example of this in the manual, I think under run-time system.


Fred Sullivan
Department of Mathematical Sciences
State University of New York at Binghamton
Email: sullivan@marge.math.binghamton.edu
Fred Sullivan
Department of Mathematical Sciences
State University of New York at Binghamton
Email: sullivan@marge.math.binghamton.edu