Hi
I am trying to modify a record with HModify().
Is the "RaceID" a declared key in the analysis? Is it a unique key with no duplicates?
I noticed the //info("..."). Obvious dead give away of a Clarion user that uses MESSAGE('...') because the debugger is difficult to use. Not the case with WinDev. Remember how easy it was to use the CPD 2.1 debugger? I suggest you read up on the WD debugger and set some STOPs and check the values you are passing, and not just hFound. Here is why...
Things are done a little different in WD than Clarion because of the greater options built into WD.
hSeek(FileName,KeyName,Value) sets a pointer to the file, like the Clarion:
FieldInKey = Value
SET(FileKeyName,FileKeyName)
hReadSeek(FileName,KeyName,Value) sets a pointer and reads the next record, like Clarions:
FieldInKey = Value
SET(FileKeyName,FileKeyName)
NEXT(FileName)
hFound is much like checking ERRORCODE() except more powerful. ERRORCODE() will advise you of file access error (37, 5, etc), while hFound will tell you is if the correct record was found (in addition to file errors) but based upon your original command...
Your command, hReadSeek, just reads the first record based upon your Value (you are SETing and reading). It does not guarantee you have read the record you really wanted to find (Value). Therefore, hFound will tell you (based on your original command) that you have found a record.
Much like Clarion, once you do the NEXT(FileName) you may not have what you think you have. In Clarion the next lines would be:
IF ERRORCODE() then DoWhateverYouDoWithErrors. //this is hFound
IF FIL:FieldInKey = Value
..Change And PUT a record
ELSE
..ADD a record
END
I don't see this same Value check in your WD code, just hFound. If there is ANY record in the Hyperfile and its not the last, with hReadSeek hFound will return TRUE, just like Clarion will not post any ERRORCODE() when a record (even the "wrong" one) is found.
If you use hReadSeek, you will either
a) do it the hard way and write the code for checking the value of the record found, like Clarion, or
b) use the hIdentical option in your command.
(btw,
As always there is an easier way. Use hReadSeekFirst.
hReadSeekFirst(FileName,KeyName,Value) is basically the same as:
FieldInKey = Value
GET(FileName,KeyName)
hReadSeekFirst will perform an identical search. If the exact record you want with the Value you want is NOT found, do the ELSE logic.
IF aArr[OL,45] <> "" THEN
..IF hReadSeekFirst(DEMO_Testdata,RaceID,aArr[OL,45]) THEN
....DEMO_Testdata.Demo_Version = OL + 120
....HModify(DEMO_Testdata)
..ELSE
....DEMO_Testdata.RaceID = aArr[OL,45]
....DEMO_Testdata.Demo_Version = OL + 120
....HAdd(DEMO_Testdata)
..END
..Gauge(OL, vnNumOfRec, "Importing " + vcFileName)
END
Notice I did not use hFound. The function call returned a value.
Get back to us if it doesn't work.
Art Bonds