Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 00:42 27 Nov 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 : Error Checking File access

Author Message
marcwolf

Senior Member

Joined: 08/06/2009
Location: Australia
Posts: 119
Posted: 06:26pm 21 Jan 2013
Copy link to clipboard 
Print this post

Hi Folks

If I try and read in from a file number that has not been used I get an error. Is there a way I can check this situation and not crash out of the program.

DaveEdited by marcwolf 2013-01-23
Coding Coding Coding..
Keep those keyboards coding..
RAW CODE!!!!!
 
shoebuckle
Senior Member

Joined: 21/01/2012
Location: Australia
Posts: 189
Posted: 08:28pm 21 Jan 2013
Copy link to clipboard 
Print this post

  marcwolf said   Hi Folks

If I try and read in from a file number that has not been used I get an error. Is there a way I can check this situation and not crash out of the program.

Dave


I gather that the non-existence of the file is a valid condition, so how about testing that the file exists before trying to read from it and set a flag to say that it exists or doesn't. This will work because OPTION ERROR CONTINUE will trap a non-existent file.

OPTION ERROR CONTINUE
File1=1
OPEN "MyDataFile" FOR INPUT AS #1
IF MM.ERRNO = 6 THEN File1 = 0
OPTION ERROR ABORT
...
...
If File1 = 1 THEN INPUT #1, a,b,c


Hugh
 
Print this page


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

© JAQ Software 2024