[Coco] error trapping
Bob Devries
devries.bob at gmail.com
Tue Dec 1 17:54:19 EST 2009
Willard wrote:
> SHELL "makdir foo >> /nil" should work
Outputting the error stream to /nil would work, but you would need to do all
your own error checking before and/or after the SHELL call. IMHO, it would
be easier to catch the error output to a temporary file (in the ramdisk
perhaps?), and if necessary, parse that to find any errors.
Regards, Bob Devries
--
Besides a mathematical inclination, an exceptionally good mastery of one's
native tongue is the most vital asset of a competent programmer.
Edsger W.Dijkstra, 18 June 1975
----- Original Message -----
From: "Willard Goosey" <goosey at virgo.sdc.org>
To: "CoCoList for Color Computer Enthusiasts" <coco at maltedmedia.com>
Sent: Wednesday, December 02, 2009 9:18 AM
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