Kye's fat driver - how to handle errors?
pik33
Posts: 2,397
Most of functions included in this driver returns strings instead of error codes.
For example, this:
c:=\fat.listentry(string("test"))
returs string "TEST" if there is a file called "TEST" on disk, or it aborts and returns string "Entry Not Found", if not.
Is it any method which can tell me if this function aborted or not? I patched this driver adding two functions:
so now I can do this like
and if fat.geterror==0 I can open my file and read the data from it
How can I do this without this patch I applied to the fat driver?
For example, this:
c:=\fat.listentry(string("test"))
returs string "TEST" if there is a file called "TEST" on disk, or it aborts and returns string "Entry Not Found", if not.
Is it any method which can tell me if this function aborted or not? I patched this driver adding two functions:
pub geterror result:=errorNumberFlag pub reseterror errornumberflag:=0
so now I can do this like
fat.reseterror c:=\fat.listentry(string("test")) if fat.geterror<>0 vga.writeln(c) 'rest of error handling code. File doesn't exist so create one now and fill with data
and if fat.geterror==0 I can open my file and read the data from it
How can I do this without this patch I applied to the fat driver?
Comments
Is this what you need to do?
I want to open a file if it exists and read data from it, if not, I want to create a new one with this name and fill it with data..
I did it that way:
first added these two function to the fat driver:
and then use it:
Now I can do it like this (?)
and use unpatched driver...
Please see Parallax semiconductor an006 http://www.parallaxsemiconductor.com/an006.
....
So I think what you want to do is done like this: