💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › MiscInfo › Programmin… captured on 2023-01-29 at 10:17:02.

View Raw

More Information

-=-=-=-=-=-=-


I do 

10 gosub 210
20 end

210 ONERR goto 1000
220 print chr$(4);"bload file"
230 poke 216,0: REM this turns off ONERR trapping
300 return


1000 print chr$(4);"bsave file,a$400,L300"
1010 goto 210


the program catches the error (the absence of the file on the disk)
it creates the file.  it loads the file and then turns
of ONERR trapping.

when run, it does as mentioned above. BUT when it reaches
line 300, I get "return without GOSUB in line 300" error.

is the stack getting screwed up from the ONERR?  is there
a specific method/call/peek/poke to recover from an error
in BASIC

if this method won't work, I am open to other suggestions!

rich
aiiadict AT hotmail DOT com
http://rich12345.tripod.com



> when run, it does as mentioned above. BUT when it reaches
> line 300, I get "return without GOSUB in line 300" error.
>
> is the stack getting screwed up from the ONERR?  is there
> a specific method/call/peek/poke to recover from an error
> in BASIC
>
> if this method won't work, I am open to other suggestions!
>
> rich
> aiiadict AT hotmail DOT com
> http://rich12345.tripod.com

Rich, I looked this up in an Applesoft book I have and the stack does get
messed up when ONERR is invoked in a subroutine. The book suggests using a
short ML routine (poked in from Applesoft) to correct the problem. It is two
pages but I don't have time to scan it in at the moment. I will send it to
you later on tonight if someone else doesn't come up with another answer in
the meantime.

Glenn

-- 
Personal Website: http://members.rogers.com/rg.jones/
Apple Specific Website http://members.rogers.com/apple2stuff/apple.htm
Email: Reply to apple2stuff at rogers dot com






Let's see if the memory is still working.

Add the following line:
1005 call -3288 : REM Fix the stack

And with 1005 in place, I *think* you can replace line 1010 with this:
1010 resume

One last thought. I'd probably check for the error ( peek(222) ) being "file
not found" otherwise you could end up with an endless loop if you got some
other error! I can't remember the error value. (It maybe 5 - or that
end-of-file?)
1000 e = peek(222) : if e <> 5 then poke 216,0 : print "Unexpected file
error "E : end
1002 print chr$(4);"bsave file,a$400,L300"
-- 
Peter Watson
-- Write to MSDOS disks on the Apple IIgs?
-- Impossible!  ;-)


"Rich J." <aiiadict@hotmail.com> wrote in message
news:370265cd.0404291928.1b770bf3@posting.google.com...
> I do
>
> 10 gosub 210
> 20 end
>
> 210 ONERR goto 1000
> 220 print chr$(4);"bload file"
> 230 poke 216,0: REM this turns off ONERR trapping
> 300 return
>
>
> 1000 print chr$(4);"bsave file,a$400,L300"
> 1010 goto 210
>
>
> the program catches the error (the absence of the file on the disk)
> it creates the file.  it loads the file and then turns
> of ONERR trapping.
>
> when run, it does as mentioned above. BUT when it reaches
> line 300, I get "return without GOSUB in line 300" error.
>
> is the stack getting screwed up from the ONERR?  is there
> a specific method/call/peek/poke to recover from an error
> in BASIC
>
> if this method won't work, I am open to other suggestions!
>
> rich
> aiiadict AT hotmail DOT com
> http://rich12345.tripod.com