Sequence of Operations
Some Btrieve operations can be issued at any time, such as Create (14), Reset (28), and Version (26). However, most Btrieve operations require that you open a file using the Open operation (0). Then, you must establish a position, or
currency
, in the file before you can operate on any records.
You can establish physical currency (based on physical location in the file) or logical currency (based on a key value).
•
Use one of the following operations to establish physical currency:
•
Step First (33)
•
Step Last (34)
•
Use one of the following operations to establish logical currency:
•
Get By Percentage (44)
•
Get Direct/Record (23)
•
Get Equal (5)
•
Get First (12)
•
Get Greater Than (8)
•
Get Greater Than or Equal (9)
•
Get Last (13)
•
Get Less Than (10)
•
Get Less Than or Equal (11)
After you establish currency, you can issue appropriate file I/O operations, such as Insert (2), Update (3), and Delete (4).
Note:
Always use Btrieve operations to perform I/O on Btrieve files; never perform standard I/O on a Btrieve file.
Based on your currency, you can move through the file as follows:
•
If you have established position based on physical currency, use the following operations: Step Next (24), Step Next Extended (38), Step Previous (35), or Step Previous Extended (39). The Step operations are useful for traversing a file quickly if your application does not need to retrieve the records in a specific order. The Extended operations are useful for working on a number of records at one time.
•
If you have established position based on logical currency, use the following operations: Get Next (6), Get Next Extended (36), Get Previous (7), or Get Previous Extended (37). The Get operations are useful for traversing a file in a specific order. The Extended operations are useful for working on a number of records at one time.
You cannot establish physical currency with one operation and then follow with an operation that requires logical currency. For example, you cannot issue a Step First operation and then a Get Next operation.
In data-only files, the MicroKernel does not maintain or create any index pages. You can access the records using only the Step operations and the Get Direct/Record operation (23), all of which use the physical location to find records.
In key-only files, the MicroKernel does not maintain or create any data pages. You can access records using only the Get operations, which use logical currency to find records.
When you have finished working with a file, use the Close operation (1) to close it. When your application is ready to terminate, issue a Stop operation (25).
Note:
Failure to perform a Stop operation prevents the MicroKernel from returning its resources to the operating system. This failure eventually results in unpredictable system behavior, including the possibility of crashing the computer on which the application is running.