Stores the current context of a data file: current record, filter, pointers. This allows you to temporarily suspend the current process in order for the data file to be used somewhere else (to perform checks for example). The saved context can be restored by HRestorePosition
. Then, the main process can continue.
HSavePosition is used to save:
- the number of the record used,
- the different pointers in the index (the position in the index is saved for each key),
- the current filter. You will have to use the hRPFilter constant in HRestorePosition to restore the stored filter.
// Recherche d'un enregistrement
HReadSeekFirst(Client, Nom, Nom)
WHILE HFound(Client) = True
// Sauve le contexte en cours
nPos = HSavePosition(Client, Nom)
// Vérification d'un client d'un autre nom
HReadSeek(Client, Nom, Nom2)
IF HFound() = True THEN Compteur = Compteur + 1
// Restaure le contexte
<Result> = HSavePosition([<Data file> [, <Item>]] [, <Options>])
- Number of the position that was saved,
- -1 if an error occurred.
<Data file>: Optional character string
Name of data file, view or query used. If this name is not specified, HSavePosition will use the last data file used by the last HFSQL management function (function starting with "H").
<Item>: Optional character string
Name of the item used. If this parameter is not specified, function HSavePosition saves the positions of all fields for which a route is in progress.
<Options>: Optional integer constant
Used to configure the backup:
This parameter is not supported.
Example for managing the positions in a data file
can be used in the following cases for example:
- form used to display a record and to browse the data file according to a key. Another window is called to display the data as a table. The management of the positions makes it possible to simply return to the correct Record in the course of the files.
- viewing a data file in a Table control. When selected, the record is displayed as a form, with the possibility of browsing through forms. The position management allows you to display the Table control again while being properly positioned on the data file.
Caution: all functions that open or close a data file reset the context numbers (e.g. HCreation
- The number of calls to HSavePosition is not limited.
- You have the ability to nest HSavePosition and HRestorePosition for the same data file.
- If the record pointed during the call to HSavePosition is deleted, HRestorePosition cannot be called anymore.
Repositioning by OLE DB and Native MySQL, DB2 and Informix Connectors
If the database or the status of browse (re-initialized browse for example) does not allow you to directly reposition on the record, the positioning is performed in the cache of records read.
The following functions reinitialize the browse:
This operating mode is the same in Java.
Business / UI classification: Business Logic