Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 3 Jahren, 1 Monat
Letzter Beitrag:
vor 3 Jahren, 1 Monat
Beteiligte Autoren:
Eric Wiegert, GuenterP, Ola

Clarification for HSavePosition/HRestorePosition?

Startbeitrag von Ola am 11.05.2015 08:05

I find the documentation for HSavePosition/HRestorePosition a little difficult to understand.


According to help HSavePosition "saves the positions of all the items for which a browse is in progress".

I wonder, what does the "position of an item" mean and what is it used for?

Obviously it is NOT the values of the items, because, according to documentation, items have to be separately saved with the "hSaveItems" constant, and this is not done by default.

For example, I want to handle two records of the same file in a process in the following way:

1. I read record A and change some of its item values
2. Then I need to read record B to get one item's value from it
3. Then I continue changing the items of record A and
4 finally Hmodify record A.

So, I suppose I have to:

1. Read record A and change some items of it
2. FilePos is int = HSavePosition(File,hSaveItems)
3. HReadSeekFirst(record B)
4. Save the necessary item from record B to a variable
5 HRestorePosition(FilePos)
5. continue changing values of items of record A
6. HModify(record A)

Is this correct and sufficient to avoid any mess-up between the two records?

Best regards


Hi Ola,

in priciple, the file pointer of a file is saved. Which means that you can return to the previously found record without initiating another HReadSeek(). I'm using HSavePosition / HRestorePosition a lot. I can navigate the same file without using an Alias. If I want to come back to that record, I just have to issue an HRestorePosition and I'm there again.

von GuenterP - am 11.05.2015 09:33
Hi Ola

There are several uses for HSavePosition / HRestorePosition as Guenter already exemplified.

If you have a window/form that possibly does a procedure (exp. look-up) using (For, For Else, Loop or While) if this procedure encounters an error or you issue a "Break" you must issue a HSavePosition at the begining of the procedure and issue a HRestorePosition to return to the original context in the file since the procedure never complete successfully.

von Eric Wiegert - am 11.05.2015 14:00
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.