[Coco] error trapping
Wayne Campbell
asa.rand at yahoo.com
Wed Dec 2 19:48:39 EST 2009
I just got this post. I guess you posted it before I posted my own reply. You have sshown me something I didn't think about, or realize might be necessary. I've never cleared the cc field before making the call. I have had no significant problems with not doing it, but I can see where there could be a time when not clearing it could cause garbage to be read by some process that requires knowing the value before processing it.
I use something similar to it in my error traps. The first statement checks to see if the er number is 0 or not, before assigning ERR to it. This way, I can bypass unnecessary steps in the file creation routines.
Also, my routine ended up being shorter than yours, so I need to compare the differences and see what you are doing that I didn't think about.
Thanks for the help. :)
Wayne
________________________________
From: Willard Goosey <goosey at virgo.sdc.org>
To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
Sent: Tue, December 1, 2009 2:18:18 PM
Subject: Re: [Coco] error trapping
On Tue, Dec 01, 2009 at 01:58:31AM -0800, Wayne Campbell wrote:
> I need to know how to trap an error generated by the makdir command
> when it's being executed with a SHELL statement in a Basic09
> subroutine.
SHELL "makdir foo >> /nil" should work, as long as nil and VRN are in
the kernel. (All REAL operating systems have a null device! :-)
Otherwise, you can do some magic to check to see if the dir exists
first...
Here is my attempt at that magic, based on the C system call access()
But it has not been extensively tested. (In particular I'm not sure
name will get the full size if passed
"/dd/extra/long/path/thats/longer/than/basic09/default/string/length"
) On the other hand, it's not a fatal error if the file can't be
opened.
PROCEDURE access
PARAM name:STRING; perm:BYTE; result:BOOLEAN
(* access checks to see if file <name> can be opened with
(* permissions <perm> and returns the result in <result>
(*requires syscall
(*Willard Goosey
TYPE registers=cc,a,b,dp:BYTE; x,y,u:INTEGER
DIM path:BYTE
DIM regs:registers
DIM callcode:BYTE
DIM newname:STRING[100]
(*make sure filename ends in <cr>
newname:=name+CHR$($0D)
(*clear random garbage from regs struct
regs.cc:=0
regs.b:=0
(* PRINT "before syscall"; regs.cc
(* open #path,name:perm
(* can't actually do that :-(
(* open refuses to let its perms be in a variable.
callcode:=$84
regs.a:=perm
regs.x:=ADDR(newname)
RUN syscall(callcode,regs)
path:=regs.a
IF regs.b=0 THEN
result:=TRUE
(* CLOSE #path
(* have to do this the hard way too
callcode:=$8F
regs.a:=path
RUN syscall(callcode,regs)
ELSE
result:=FALSE
(*PRINT "regs.cc was"; regs.cc
(*PRINT "regs.b was "; regs.b
ENDIF
END
Willard
--
Willard Goosey goosey at sdc.org
Socorro, New Mexico, USA
I search my heart and find Cimmeria, land of Darkness and the Night.
-- R.E. Howard
--
Coco mailing list
Coco at maltedmedia.com
http://five.pairlist.net/mailman/listinfo/coco
More information about the Coco
mailing list