>Hi to all,
>
>Is there a way to know if a table is locked in the middle of a transaction before opening it?
There's no way to check the lock status of a VFP table if you haven't USEd it.
>I tried using flock() but this works only if the table is open. What about checking a table lock status if it is closed? Isn't there a function as "locked()"?
>
ISFLOCKED()and ISRLOCKED() only reflect whether you presently hold a lock on a given table or record in the table respectively, not whether you could be granted a lock on it. The LOCK concept with VFP operates on a Test and Set basis - you try to gain a lock, and either get it and have it confirmed, or fail to get it and get it denied. You can't check if something is available to lock before opening the resource or trying to gain the needed access.
FLOCK() is not the same thing as USE EXCLUSIVE - you may have a table opened and acquire an FLOCK()< but cannot perform the restricted set of operations that need EXCLUSIVE access to the file such as PACK. The idea of FLOCK() is that others can read but only you can write, while USE EXCLUSIVE says that only you may have any access at all to the file for the duration of its reference.