Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 5 Jahren, 1 Monat
Letzter Beitrag:
vor 5 Jahren, 1 Monat
Beteiligte Autoren:
RAUL2, Alexandre Leclerc, Al, ICI

HSeekFirst() vs HReadSeekFirst()

Startbeitrag von RAUL2 am 20.05.2013 19:40

Hello guys.
I'm just trying to understand the differencies between these 2 functions. What I need to accomplish is to find out whether or not a record exists for a comp key.

For instance, let's say I have a relation file with just 2 fields: CustomerId and OrdersId (just an example.) Now I need to know if customer 4 and order 1230 exists in that file. What function will be better in this case?

I only need to know if that combination exists, nothing else. I don't need to modify or erase the record. It seems to me that HSeek...() looks for values in the index only (this is my case.)

Kind regards.

Antworten:

Hello Raul2

Its a speed issue, both commands find the same record, but Hseek is faster because it does not read the data into a memory buffer. This would make a difference in HF Classic but I doubt it would matter much in HFCS.

Regards
Al

von Al - am 20.05.2013 21:56
RAUL

HReadSeekFrst("1230") make your FileToScreen() display record 1230 on screen
HSeekFirst("1230") make your FileToScreen display record 1 on screen

Record pointer is not moved on 1230 just found and go back on 1.

So, conclusion, HSeekFist is used when you just need to check existence of key and do some other things, but if you need to read/display/modify that "1230" record you must to use HReadSeekFirst()

von ICI - am 21.05.2013 06:06
Hi ICI,

Just a little detail: the record pointer is moved when using HSeekFirst(), but as already pointed out, the data is not loaded into the record buffer. (HFileToScreen will dsiplay the previous loaded buffer.) To get the record number you must call HRecNum() then after you can use HRead() to load the data. (Or in one operation: HRead(file,HRecNum()). This is useful for some operations where loading the data is useless.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 21.05.2013 13:23
Thank you guys for your replies! I understand the difference now.
Kind regards.

von RAUL2 - am 21.05.2013 20:46
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.