>If you read carefully Cetin's answer you may solve the puzzle. If you get 5 from FERROR() the wrong path or file name possibility is eliminated.
>What is left is:
>- Your dbf is already open exclusively.
>- You issue FOPEN() for write access
>Note that FOPEN() with a second parameter 1,2,11,12 is the equivalent of USE ... EXCLUSIVE
Try simple experiment (substitute with the name of your table):
local lnHandle
lnHandle = fopen('jobs.dbf',0)
? 'First time: '+transform(m.lnHandle)
if lnHandle>0
? fclose(m.lnHandle)
endif
select 0
use jobs shared in 0
wait window "Let's see..."
lnHandle= fopen('jobs.dbf',0)
? 'Second time: '+transform(m.lnHandle)
if lnHandle>0
? fclose(m.lnHandle)
endif
?ferror()
use in select('jobs')
use jobs excl
? fopen('jobs',12)
use in select('jobs')
If it's not broken, fix it until it is.
My Blog