Subject Re: How to Catch In Use By another error?
From Akshat Kapoor <akshatkapoor76@gmail.com>
Date Mon, 20 Nov 2017 09:08:36 -0500
Newsgroups dbase.getting-started

Michael Wrote:

> Thanks for that Mervyn, yeah, actually my code is very similar, almost identical but I found if the file was in use, it triggered an error and the catch wouldnt work because the program halted an in use error.
>
> if the f.open returns true, wouldnt it have the same effect? If it opens the file it will only trigger a "file already in use" error if i try to write to it, it doesnt mean its its not still locked and being written to. It will only open it in read mode.
>
> The file im opening is only a txt file. could I use set reprocess to -1 to keep trying until its unlocked?
>
> or is that different again?
>
> The delay idea is probably the best way, if there is no other way to check if in use.

This is just a wild guess copied from OLH for dirExt().
My theory is that if a file is being edited then windows marks the file readonly or changes its attribute to R.

#define ARRAY_DIR_NAME 1 // Manifest constants for columns returned by dirExt( )
#define ARRAY_DIR_SIZE 2
#define ARRAY_DIR_DATE 3
#define ARRAY_DIR_TIME 4
#define ARRAY_DIR_ATTR 5
#define ARRAY_DIR_SHORT_NAME 6
#define ARRAY_DIR_CREATE_DATE 7
#define ARRAY_DIR_CREATE_TIME 8
#define ARRAY_DIR_ACCESS_DATE 9
aFiles = new Array() // Array will be resized as needed
nFiles = aFiles.dirExt("\*.*", "HS") // Include Hidden and System files
for nFile = 1 to nFiles
   ? aFiles[ nFile, ARRAY_DIR_NAME ]  
   ?? aFiles[ nFile, ARRAY_DIR_ACCESS_DATE ] at 25
endfor

In the above code we are including Hiidden & System Files.
Windows used to (not sure about the currrent scenario) change the attribute of file being modified to R so that other users/process do not delete it.

Can the above code be modified to access read only files (and check if the required files is there or not if not then it is not in use)

I have not used directory functions so it is just a wild guess that we can check the attributes of a file in dBase

If there is a way using extern etc. then you have your solution
Regards
Akshat


Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0