PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → HF question
HF question
Débuté par noodel, 21 mai 2015 21:11 - 10 réponses
Posté le 21 mai 2015 - 21:11
I want to search in a data file for a certain record ...once i have found the record i would like to find out the unique id of the found record....witouth loading it in a control ,table,first...

Hreadfirst
then i find whether the record excists or not
but then how to retrieve unique id of the found record?

thanks for the help in advance
Posté le 21 mai 2015 - 21:33
Hi Noodel,

IF HReadFirst(YourFile,FileKey) THEN
Info(YourFile.FileKey)
END

should do it ...
Posté le 21 mai 2015 - 22:02
lets say info is my data file and they keys are adress / name

Hreadseekfirst( Info.name,edt_control)
edt control contains a name (lets say simon)found in the data fille amoung several other names (gorge/simon/chelsy/chapie)
i need a way to find the unique key of the retrieved "name"
so if i do hreadseekfirst...i wil find out that the the name simon is in existing record
buth how do i find out in what record it is stored?in this case 2
Posté le 22 mai 2015 - 00:12
Noodel,

What are you looking to get? A unique id or the record number? You don't tell us all the fields in your file:confused:
Posté le 22 mai 2015 - 01:24
Hi noodle,

This is not a hyperfile question but more general database / file question I guess. I'll give it a go.

your db table

id name
1 john
2 gerald
3 tim

With hreadfirst(file, fileID ) the pointer is set to the first record of the file
with hreadseekfirst( file , fileID, table.colID) the Id found in the table is used to point it to and ID in the dbtable.

OK when you do hreadfirst on this file the pointer is going to the first record. This is 1 for the id and "john" for the name.

If you do this with hreadseekfirst ( file , fileID, 1 ) then it is pointend to the first record as well.

Ok so we are at the first record. Now we can use everything in the file like this

myname is string
myname = file.name

In this case myname would be "john"

If you do this: hreadseekfirst ( file,fileID,2) then this would be like this

myname is string
myname = file.name

In this case myname would be "gerald"

Your example. If you do a search on a name. (This can be done even without a key on name with following syntax)

hreadseekfirst ( file, file.name, "Simon")

//Then the Id would be:

id is int
id = file.id
Id would then in your case be 2

I hope this helps

regards
Allard
Posté le 22 mai 2015 - 09:00
Hi Allard
Great example. But I am afraid you confuse it a bit by introducing the name Simon.
The names uou use in the example are:
1 john
2 gerald
3 tim

Best regards
Viggo Poulsen
Posté le 22 mai 2015 - 10:02
Hi,

The name "Simon "is from the examle of Noodle,

Quote
Hreadseekfirst( Info.name,edt_control) edt control contains a name (lets say simon)found in the data fille amoung several other names (gorge/simon/chelsy/chapie) i need a way to find the unique key of the retrieved "name" so if i do hreadseekfirst...i wil find out that the the name simon is in existing record buth how do i find out in what record it is stored?in this case 2



regards
Allard
Posté le 22 mai 2015 - 13:40
Hi Allard

Ah, didn't see that. Sorry.

Best regards
Viggo Poulsen
Posté le 22 mai 2015 - 15:09
Hi,

Stefan already explained how to find the unique ID.
If you mean the recordnumber, it can be found using hRecnum(FileName).

Regards,
Piet
Posté le 22 mai 2015 - 20:29
I have found my problem
it had to do with HReadSeekFirst syntax , The code runed buth because of orange light in the syntax not as desired
bydeway can somebody link me some good videos / books around programing with windev i have a lot to catch up with...i found some on youtube buth most are french
thanks for the help

Noodel
Posté le 23 mai 2015 - 01:03
Hi,

First do the tutoral. Donnot just look at it . Do the examples even if you think you understand them an thus skip a view. It will take some time but later on it will save you weeks.

Then look at the examples provided bij windev. If you have done the tutorial you should be able to understand the coding syntax and thus the "extra "specific stuiff where the example is all about.

This is just a thing you have to do. Developing in windev has a certain way and you have to get that.

Then you have to get familiar with the help system. It is great. it has all kinds of coding samples and explinaitions on specific functions.

The lunrning curve is not big. after doing these steps you will be able to create great applications.

Then if you still need to you can look at the youtube video's posted by pete (the people form the us have posted some great videos that where webinars.)
On webdev they have some cool video's ( as well )

Hope this helps

regards

Allard