Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00521938
Message ID:
00522103
Views:
14
>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) && returns number (file opens)
? 'First time: '+transform(m.lnHandle)
if lnHandle>0
  ? fclose(m.lnHandle) && return .T. (file closed)
endif  
select 0
use jobs shared in 0
wait window "Let's see..."
lnHandle= fopen('jobs.dbf',0) && returns -1 (unable to open file)
? 'Second time: '+transform(m.lnHandle)
if lnHandle>0
  ? fclose(m.lnHandle) 
endif  
?ferror()
use in select('jobs')
use jobs excl
? fopen('jobs',12) && returns -1 (unable to open file)
use in select('jobs')
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View