Sets the position on the last data file record whose value for a specific item is less than or equal to a sought value.
The record is not read.
The number of the current record is modified when it is returned by
HRecNum. For the functions that handle the current record number (
HDelete,
HRead,
HModify, ...), the value of this number is not updated: you must use
HRecNum(). For example: not to do:
but
HDelete(Customer, HRecNum())
The reading is performed from the lowest to the greatest value of the browse item (see the remarks for more details).
Caution: The record loaded in memory is not modified. The HFSQL variables (Customer.Name for example, which means the Name item of Customer file) are not updated.
In most cases,
HSeekLast sets the position in the data file to browse through the records that correspond to a condition.
HNext is used to position on the next record corresponding to the condition.
Several cases may occur after the call to HSeekLast:
- a record corresponding to the condition was found: HFound returns True
- the data file is empty or there is no record corresponding to the condition: HOut returns True
Remarks:
- By default, HSeekFirst and HSeekLast are used to perform an exact-match search.
- By default, HSeekLast is used to perform a generic search.
Versions 15 and later
New in version 15
Versions 17 and later
New in version 17
Versions 18 and later
New in version 18 Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Versions 21 and later
New in version 21The reading is performed from the lowest value to the greatest value of search item (see the notes for more details).
Caution: The record loaded in memory is not modified. The HFSQL variables (Customer.Name for example, which means the Name item of Customer file) are not updated.
In most cases, HSeekLast sets the position in the data file to browse through the records that correspond to a condition.
Several cases may occur after the call to HSeekLast:
- a record corresponding to the condition was found, locked (if necessary) and loaded in memory: HFound returns True.
- the data file is empty or there is no record corresponding to the condition: HOut returns True.
- the function tries to lock a record that is already locked in read-only: HErrorLock returns True and HOut returns True.
Locks are managed only on HFSQL Client/Server data files or on data files handled by a Native Connector. An HFSQL Mobile record cannot be locked. Indeed, the operating system of Pocket PC does not allow you to lock records.
Versions 15 and later
New in version 15
Versions 17 and later
New in version 17
Versions 18 and later
New in version 18 Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Versions 21 and later
New in version 21Remarks
Generic search/Exact-match search
- Generic search (mainly on the Character String items): Finds all records starting with the specified value.
For example: When a generic search is performed on "Smith" (for the NAME item), all records whose Name item starts with "Smith" will match the search. Therefore, the record containing "Smither" will correspond to the search (HFound returns True). - Exact-match search: Finds all records that exactly correspond to the specified value.
For example: When an exact-match search is performed on "Smith" (for the NAME item), HFound returns True for the records whose item exactly matches "Smith". - Examples or searches performed on CUSTOMER file sorted by name:
| | | | | |
Sought value | Options | HSeekLast sets the position on the record | HFound returns | HOut returns | Explanations |
Durand | | 6 | True | False | Durand exists. The beginning of data file was not reached yet. |
Dupuis | | 5 | False | False | Dupuis does not exist. Positioning on the first lower value (Moore). The beginning of data file was not reached yet. |
Moor | hGeneric | 5 | True | False | Moor does not exist but the search is generic, and Moore is found (among others). The beginning of data file was not reached yet. |
Moor | | The record was not found (no move) | False | False | Moor does not exist. The beginning of data file was not reached yet. |
Bernard | | The record was not found (no move) | False | True | Bernard does not exist. Positioning on the first lower value (this value does not exist): The beginning of data file was reached. |
Performing a search on a composite key
Several methods can be used to perform a search on a composite key:
Using a list of values
The following syntax is used to perform a search on a composite key:
HSeekLast(<File name>, <Name of composite key>, ...
[<Search value of first element of composite key>,
<Search value of first element of composite key>, ...])
Example:
// Find the record
HSeekLast(Customer, LastName_FirstName, ["Moore", "Vince"])
Search on an array item
The search is performed on the first array element (element whose subscript is 1). To perform a search on the other array elements, use the filters or queries.
Search and filter
If a filter is enabled (
HFilter), the search takes the filter into account.