PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Clarification for HSavePosition/HRestorePosition?
Clarification for HSavePosition/HRestorePosition?
Iniciado por guest, 11,may. 2015 10:05 - 2 respuestas
Publicado el 11,mayo 2015 - 10:05
I find the documentation for HSavePosition/HRestorePosition a little difficult to understand.

<a class="ExternalLink" rel="nofollow" target="_blank" href="http://doc.windev.com/?3044136&product=WD">http://doc.windev.com/&hellip;</a>

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
Ola
Publicado el 11,mayo 2015 - 11:33
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.
Publicado el 11,mayo 2015 - 16:00
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.