Do not wait for semaphores

Command group Flag affected Reversible Execute on client Platform(s)
Changing data NO YES NO All

Syntax

Do not wait for semaphores

Description

This command causes all commands which set semaphores to return with a flag clear if the semaphore is not available.

If Do not wait for semaphores is run first in a method, it will ensure that any subsequent commands that lock records, such as Prepare for..., Update commands, do not wait for records to be released. It causes the command to return a flag false and control to return immediately to the method, if a record is locked.

Semaphores

Semaphores are internal flags or indicators set in the data file to show other users that the record has been required elsewhere for editing. Semaphores are only set when running in multi-user mode, that is, the data file is located on a networked server, a Mac volume or on a DOS machine on which SHARE has been run.

The commands which set semaphores are Prepare for editPrepare for insertUpdate files and Delete, and also, if prepare for update mode is on and the file acted upon is Read/Write, Single file find, Load connected recordsSet read/write files, all types of FindNext, and PreviousUpdate files commands lock the whole data file while indexes are re-sorted.

The Edit/Insert commands always wait for a semaphore, as do automatic find entry fields.

The example below illustrates how any command which causes a change in record locking requirements can fail (returning flag false). If, when in ‘Prepare for’ mode, a Single file find cannot lock the new record, it returns a flag false. This could mean either that the record could not be found, or that it was in use by another workstation. For this reason, it was made read-only before the Single file find and then changed to read/write. Note also that Update files can fail if the file cannot be locked while the indexes are re-sorted.

Example

Do not wait for semaphores
Prepare for edit
If flag true
  Set read-only files {fAccounts}
  Single file find on fAccounts.Code (Exact match)
  If flag false
    Cancel prepare for update
    Quit method kFalse
  End If
  Repeat
    Set read/write files {fAccounts}
  Until flag true
  Repeat
    Update files
  Until flag true
End If