Finally, we have provided a couple of small predicates that are handy in special circumstances. The predicate availableems will in DOS return the amount of available ems. This can be used before a call to db_open or db_create in order to see if there is enough space for placing the database in_ems.
availableems(Size) /* (real)-(o) */
Another predicate str_ref can be used to convert a database reference number to a string so it can be inserted in a B+ Tree.
str_ref(Str,Ref) /* (string,ref)-(i,o)(o,i)(i,i) */
Visual Prolog's external database system adds power, speed, and efficiency to your database applications. These are the major points covered in this chapter:
1. External database terms are stored in chains, which you can access directly with database reference numbers; these reference numbers belong to the predefined ref domain.
2. Individual databases are identified by a database selector, which belongs to the standard domain db_selector.
3. You can store your external database in three locations, depending on which alternative you use for the predefined place domain:
a. in_file places the database in a disk file
b. in_memory places it in memory
c. and in_ems places it in EMS-type expanded memory (same effect as in_memory on non-DOS platforms
4. If you want to sort the terms in your database, you'll use B+ trees. Like databases, individual B+ trees are identified by a B+ tree selector of the standard domain bt_selector.
5. Each entry in a B+ tree node consists of a key string (also known as an index), which identifies a record, and the database reference number associated with that record.
6. tree keys are grouped in pages, and the number of keys stored at a node is specified by the tree's order.
7. Filesharing is done by grouping the predicates that access the database into transactions.