Hi all,
so i'm writing a KAREL program of which part of it logs to a file on USB (UD1) if the user has selected choice to log.
if the user HAS selected choice to log then the USB MUST be inserted for logging - if not the program must abort it's process
so...
OPEN FILE LOG_FILE('AP', fn)fstatus = IO_STATUS(LOG_FILE)
fstatus is always zero whether USB plugged in or not
so it was suggested to me to try opening the file read-only as that gives the correct IO status...
OPEN FILE LOG_FILE('RO',fn)
fstatus = IO_STATUS(LOG_FILE)
fstatus is zero if USB in and file already exists
fstatus is 2014 if USB in and file doeasn't exist yet (FILE-014 File not found)
fstatus is 2014 is USB is not in (FILE-014 File not found)
It seems there’s no difference between..
- “the file doesn’t exist because usb NOT plugged in” (2014) and
- “the usb IS plugged in but the file doesn’t exist on it” (2014)
another suggestion was to use
flist : ARRAY[2] OF STRING[40]
FILE_LIST(fn, 0, 3, flist, n_files, fstatus)
but similarly, fstatus is always 0 whether USB is in or not. Hmmmm….
basically all i need is,..
IF USB connected THEN
append log file
ELSE
ABORT
ENDIF
Anyone have any ideas what's going on, or how to solve it?
Any help would be extremey appreciated
Chris