PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → corrupt data file?
corrupt data file?
Iniciado por guest, 05,feb. 2018 18:31 - 3 respuestas
Publicado el 05,febrero 2018 - 18:31
While updating a field in a file from some other data (HF files imported from XLS) I came upon the following problem using the following code:
arrFiles is array of strings = ["Beans$","Choc$","Frozen$","Fruit$","Grains$","Juice$","Misc$","Nuts$","Olives$","Pasta$","PB$","Snacks$","Spices$"]
sFile, sItem, sTmp, sSC_Code is string
i, nMax is int
nMax = ArrayCount(arrFiles)
FOR i = 1 TO nMax
sFile = Upper(arrFiles)
HReadFirst(sFile)
WHILE NOT HOut(sFile)
sSC_Code = ""
sItem = {sFile +".Item"}
IF sFile = "SPICES$" THEN
sSC_Code = NoSpace({sFile +".ScaleCode"})
ELSE
sTmp = NoSpace({sFile +".SC_CODE"})
IF Left(sTmp,1) = "S" THEN
sSC_Code = sTmp // SCCODE
END
END
HReadSeekFirst(TNF_Item,ITMDESC,sItem) // THIS FAILS
IF HFound(TNF_Item) THEN // AND OF COURSE SO DOES THIS
TNF_Item.SCODE = sSC_Code
HModify(TNF_Item)
ELSE
Info(sItem +" not found!")
END
HReadNext(sFile)
END
END

The ITMDESC in TNF_Item is defined as string[50] unique key. The results shown in Step1.png and Step2.png don't seem to make any sense. Step1 shows status just before HReadSeekFirst and Step2 shows just after.
[attachment 2580 Step1.png]
[attachment 2581 Step2.png]
Publicado el 05,febrero 2018 - 19:31
Hi

I guess you have only double-quote string issue ie parsing problem.

Pls see below

sDQ is string = """"
sSql is string = "myString needs " + sDQ + "quote it right here" + sDQ
info(sSql)

HTH

King
Publicado el 05,febrero 2018 - 21:01
It was unfortunate that the first item in the file was # 817 Basmati Rice since the reason that it couldn't be found was due to HReadSeekFirst not being able to handle the # sign at the beginning (well, maybe anywhere). It also failed to find an item with a / in the description but everything else worked.
King - does your solution solve this? Should all HReadSeekFirst's on a text string be handles this way?
Garry
Publicado el 05,febrero 2018 - 23:31
I finally figured it out AND I think I had this problem once before and someone (probably Fabrice) pointed out the solution. When creating the index key just put a check mark in the Space, punctuation and special char. sensitive option.