Basic provides functions and commands to help ensure database integrity: Lock() and Unlock() function, and TStart, and TCommit commands. We'll cover these in preparation for adding editing capabilities to the myBASlookup routine. These commands usually appear near each other. In general, you should use them in this way:
Select a record for editing.
Lock() the record.
Get the updated data for the record.
TStart a transaction.
Store the new data.
TCommit the transaction.
Unlock() the record.
You use the Lock() command to prevent multiple processes from updating the same record at the same time. But it only works by convention: all the code throughout an application that updates a given global must try to Lock() the record that is to be updated, and Unlock() it when finished. If one routine uses Lock(), but another doesn't, nothing prevents the second routine from updating the record while the first routine has it locked.
You use the TStart and TCommit commands to protect database transactions. A transaction is simply a series of changes (insert, update, delete) to the database. You need to ensure that an entire transaction completes, or that none of it completes. This guarantees that all the globals in a transaction (for both data and indices, for example) remain in sync.