2.2.1 Finding record locations in a table
Records are addressed by their offset in the table (file). As records have generally non-fixed length, searching is often required. The predicates below allow for finding records in the file.
- get_table_attribute(+Handle, +Attribute, -Value)
- Fetch attributes of the table. Defined attributes:
file
Unify value with the name of the file with which the table is associated. field(N)
Unify value with declaration of n-th (1-based) field. field_separator
Unify value with the field separator character. record_separator
Unify value with the record separator character. key_field
Unify value with the 1-based index of the field that is sorted or fails if the table contains no sorted fields. field_count
Unify value with the total number of columns in the table. size
Unify value with the number of characters in the table-file, not the number of records. window
Unify value with a term Start -
Size, indicating the properties of the current window. - table_window(+Handle, +Start, +Size)
- If only part of the file represents the table, this call may be used to define a window on the file. Start defines the start of the window relative to the start of the file. Size is the size in characters. Skipping a header is one of the possible purposes for this call.
- table_start_of_record(+Handle, +From, +To, -Start)
- Enumerates (on backtracking) the start of records in the table in the region [From, To). Together with read_table_record/4, this may be used to read the table's data.
- table_previous_record(+Handle, +Here, -Previous)
- If Here is the start of a record, find the start of the record before it. If Here points at an arbitrary location in a record, the start of this record will be returned.