Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:23 08 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : OPTION ERROR CONTINUE gone from 5.4 DOS.

Author Message
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 11:11pm 02 Aug 2017
Copy link to clipboard 
Print this post

The OPTION ERROR [CONTINUE | ABORT] commands, which were used to check for file i/o errors, are not in the DOS V 5.4 documentation. Instead I find ON ERROR [ABORT | IGNORE | SKIP [nn] | CLEAR]. I was going to use this generic FIO%() function to open all my files but I'm not sure how to use the new error checking commands. Help please.

Paul in NY


' in the mainline I use this statement to open any file
if FIO%(FIlblN$,FIlblB%,"R")=0 then CRAsh*t("UBLEWIT! Can't open file "+FIlblN$)
' then I do something with the file


FUNCTION FIO%(fn$,bf%,rwa$) '^1=open, 0=fail, where rwa$= [R|W|A]
OPTION ERROR CONTINUE
SELECT CASE rwa$
CASE "R"
OPEN fn$ for input as #bf%
CASE "W"
OPEN fn$ for output as #bf%
CASE "A"
OPEN fn$ for append as #bf%
END SELECT
if MM.ERRNO <> 0 then FIO%=0 else FIO%=1
OPTION ERROR ABORT
END FUNCTION 'FIO%(fn$,bf%,rwa$)

SUB CRAsh*t(st$) ' close all open files and crash
LOCAL i%
OPTION ERROR CONTINUE
for i%=1 to 10:close #i%:next i%
OPTION ERROR ABORT
ERROR st$ ' crash the program
END SUB 'CRAsh*t(st$) ' close all open files and crash

 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 11:16pm 02 Aug 2017
Copy link to clipboard 
Print this post

Hey, look at that!! The web site doesn't like the vernacular term referring to the ubiquitous product of defecation. It cleaned up my procedure name. In the future I'll substitute CRASHtheWHOLEdarnedTHING(st$) for my usual CRASH_IT(st$).

Paul in NY
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 03:20am 03 Aug 2017
Copy link to clipboard 
Print this post

This should work (not tested):


' in the mainline I use this statement to open any file
if FIO%(FIlblN$,FIlblB%,"R")=0 then CRAsh*t("UBLEWIT! Can't open file "+FIlblN$)
' then I do something with the file


FUNCTION FIO%(fn$,bf%,rwa$) '^1=open, 0=fail, where rwa$= [R|W|A]
ON ERROR IGNORE
SELECT CASE rwa$
CASE "R"
OPEN fn$ for input as #bf%
CASE "W"
OPEN fn$ for output as #bf%
CASE "A"
OPEN fn$ for append as #bf%
END SELECT
if MM.ERRNO <> 0 then FIO%=0 else FIO%=1
ON ERROR ABORT
END FUNCTION 'FIO%(fn$,bf%,rwa$)

SUB CRAsh*t(st$) ' close all open files and crash
LOCAL i%
ON ERROR IGNORE
for i%=1 to 10:close #i%:next i%
ON ERROR ABORT
ERROR st$ ' crash the program
END SUB 'CRAsh*t(st$) ' close all open files and crash

Geoff Graham - http://geoffg.net
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 09:24am 03 Aug 2017
Copy link to clipboard 
Print this post

Thanks Geoff, I kind of figured that was what you intended.

BTW, in several places in the various manuals you use the variable name STR for an array sort of like this:

DIM AS STRING str (5, 10) LENGTH 20


This looks funny as heck. I figured that str would be a reserved word. Will it conflict with the function str$()? Is the space allowed between the variable name and its array dimension brackets?

Paul in NY
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1986
Posted: 09:59am 03 Aug 2017
Copy link to clipboard 
Print this post

  Paul_L said  
This looks funny as heck. I figured that str would be a reserved word. Will it conflict with the function str$()?


this was touched on in this thread
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 01:59am 05 Aug 2017
Copy link to clipboard 
Print this post

  Paul_L said  BTW, in several places in the various manuals you use the variable name STR for an array sort of like this:
DIM AS STRING str (5, 10) LENGTH 20

Thanks, yes that is a poor choice of a variable name.

I will change it forthwith.

Geoff
Geoff Graham - http://geoffg.net
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024