Specifies how many times and for how long Visual FoxPro attempts to lock a file or record after an unsuccessful locking attempt.
Syntax
SET REPROCESS TO nAttempts [SECONDS] | TO AUTOMATIC
Arguments
TO nAttempts [SECONDS]
Specifies the number of times Visual FoxPro attempts to lock a record or file after an initial unsuccessful attempt. The default value is 0, the maximum value is 32,000.
SECONDS specifies that Visual FoxPro attempts to lock a file or record for nAttempts seconds. It's available only when nAttempts is greater than zero.
For example, if nAttempts is 30, Visual FoxPro attempts to lock a record or file up to 30 times. If you also include SECONDS (SET REPROCESS TO 30 SECONDS
), Visual FoxPro continuously attempts to lock a record or file for up to 30 seconds.
A system message ("Waiting for lock ... ") appears if SET STATUS is set to ON.
If an ON ERROR routine is in effect and attempts by a command to lock the record or file are unsuccessful, the ON ERROR routine is executed. However, if a function attempts the lock, an ON ERROR routine isn't executed and the function returns false (.F.).
If an ON ERROR routine isn't in effect, a command attempts to lock the record or file, and the lock can't be placed, an appropriate alert appears (for example, "Record is in use by another"). If a function attempts to place the lock, the alert isn't displayed and the function returns false (.F.).
If nAttempts is 0 (the default value) and you issue a command or function that attempts to lock a record or file, Visual FoxPro tries to lock the record or file indefinitely. Visual FoxPro displays the system message, "Attempting to lock... Press Escape to Cancel," while attempting to lock the record or file. The lock is placed and the system message is cleared if the record or file becomes available for locking while you wait. If a function attempted to place the lock, the function returns true (.T.).
If you press ESC in response to the system message, an appropriate alert appears (for example, "Record is in use by another"). If a function attempts to place the lock, the alert isn't displayed and the function returns false (.F.).
If an ON ERROR routine is in effect and a command is attempting to lock the record or file, the ON ERROR routine takes precedence over additional attempts to lock the record or file. The ON ERROR routine is immediately executed. Visual FoxPro does not attempt additional record or file locks and does not display the system message.
If nAttempts is –1, Visual FoxPro attempts to lock the record or file indefinitely. You can't cancel the locking attempts by pressing the ESC key, and an ON ERROR routine isn't executed.
Setting nAttempts to -2 is equivalent to using the TO AUTOMATIC clause.
Visual FoxPro displays the "Waiting for lock ... " system message only if SET STATUS is set to ON.
If a lock has been placed by another user on the record or file you are attempting to lock, you must wait until the user releases the lock.
TO AUTOMATIC
Specifies that Visual FoxPro attempts to lock the record or file indefinitely (equivalent to setting nAttempts to –2
). This clause is similar to setting nAttempts to -1, except that it includes the facility to quit the attempt to lock a record or file.
The "Attempting to lock ... Press Escape to Cancel" system message appears while Visual FoxPro attempts to lock the record or file. The lock is placed and the system message is cleared if the record or file becomes available for locking while you wait. If a function is used to place the lock, the function returns true (.T.).
If an ON ERROR routine isn't in effect and you press ESC in response to the system message, an appropriate alert appears (for example, "Record is in use by another"). If a function attempts to place the lock, the alert isn't displayed and the function returns false (.F.).
If an ON ERROR routine is in effect and ESC is pressed, the ON ERROR routine is executed. If a function attempts to place the lock, an ON ERROR routine isn't executed and the function returns false (.F.).
For more information about record and file locking and sharing tables on a network, see Chapter 17, Programming for Shared Access, in the Programmer's Guide.
Remarks
The first attempt to lock a record or file isn't always successful. Frequently, a record or file is locked by another user on the network. SET REPROCESS determines whether Visual FoxPro makes additional attempts to lock the record or file when the initial attempt is unsuccessful. You can specify either how many times additional attempts are made or for how long the attempts are made. An ON ERROR routine affects how unsuccessful lock attempts are handled.
SET REPROCESS is scoped to the current data session.