Partager via


SET REPROCESS Command

Specifies how many times and for how long Visual FoxPro attempts to lock a file or record after an unsuccessful locking attempt.

SET REPROCESS TO nAttempts [SECONDS] [SYSTEM] | TO AUTOMATIC [SYSTEM]

Parameters

  • 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 is not in effect, a command attempts to lock the record or file, and the lock cannot be placed, an appropriate alert appears (for example, "Record is in use by another"). If a function attempts to place the lock, the alert is not 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 is not 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 cannot cancel the locking attempts by pressing the ESC key, and an ON ERROR routine is not 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 is not 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 is not executed and the function returns false (.F.).

  • SYSTEM
    Specifies that SET REPROCESS applies to the system data session, which controls Tables used internally, such as a database, FoxUser, .scx files, and so on.

    For more information about record and file locking and sharing tables on a network, see Programming for Shared Access.

Remarks

The first attempt to lock a record or file is not 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. SET REPROCESS SYSTEM is scoped to the system data session.

Note

Changes made in the Data tab of the Tools Options dialog box affect only the current session.

Example

SET ("REPROCESS")      && Returns the current session setting
SET("REPROCESS",1)   && Returns the system session setting

* In the config.fpw file, the following code changes the default session.
REPROCESS = 100

See Also

Reference

FLOCK( ) Function

SET DATASESSION Command

SET Command Overview

SYS(3051) - Set Lock Retry Interval

SYS(3052) - Override SET REPROCESS Locking

Other Resources

Programming for Shared Access

Commands (Visual FoxPro)

Language Reference (Visual FoxPro)