PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → How to Convert HF to Text ?
How to Convert HF to Text ?
Débuté par Marco Antonio, 15 sep. 2008 01:09 - 4 réponses
Posté le 15 septembre 2008 - 01:09
Hi
I need to convert files *.fic in *.txt delimited with commas, The WDMAP do this, but I´d like use WD language comands.
The solution HF to XML
HExportXML(CUSTOMER, "C:\TEMP\Customer.xml", hExpCreation)
and after ...
MyDoc is string
MyDoc = fLoadText("Customer.xml")
XMLtoText(extractstring(Mydoc,............)
I thing is not a better solution, so ...
any body have an other idea ?
thanks in advance
Marco Antonio
Posté le 15 septembre 2008 - 01:07
Hi Marco,
1 - there is WDCONV too. Have a look at it.
2 - fWriteLine(..) fOpen(..) a file for output and do a loop reading the file.
MyTextFileID = fOpen("C:\MyDirectory\MyTextFile")
HReadfirst(MyFile,MyUniqueKey)
WHILE NOT HOut(MyFile)
fWriteLine(MyTextFileID, NumtoString(NumericItem)+","+Nospace(Replace(TextItem,","," ")))
HReadNext(MyFile,MyUniqueKey)
END
fClose(MyTextFileID)
* Text items are not allowed to contain commas .. Replace(..) takes care of that
* Text items should not contain CR+LF
Regards,
Guenter
Posté le 15 septembre 2008 - 13:13
Actually, if we're talking about a CSV file (which I assume the original
author is), then "text items" can contain commas, and should be enclosed in
inverted commas.

Cheers...
Roger

"Jimbo" <guest@news.pcsoft.fr> wrote in message
news:25332008091422101484.13019@news.pcsoft.fr...



Hi Marco,
1 - there is WDCONV too. Have a look at it.
2 - fWriteLine(..) fOpen(..) a file for output and do a loop reading the
file.
MyTextFileID = fOpen("C:\MyDirectory\MyTextFile")
HReadfirst(MyFile,MyUniqueKey)
WHILE NOT HOut(MyFile)
fWriteLine(MyTextFileID,
NumtoString(NumericItem)+","+Nospace(Replace(TextItem,","," ")))
HReadNext(MyFile,MyUniqueKey)
END
fClose(MyTextFileID)
* Text items are not allowed to contain commas .. Replace(..) takes care
of that
* Text items should not contain CR+LF
Regards,
Guenter
Posté le 15 septembre 2008 - 16:21
Thanks Guenter / Roger
I&acute;ll use your sugestion, but...
I think that PCSOFT should by a WDlanguage function to do this, (and have to be) because WDMAPS do convert fic to text and I dont believe that they use the structure of Guenter says. If exist one HEXPORTXML function. should by easy to do one XEXPORTTXT function... or not ???

Thanks a lot

Marco
Posté le 15 septembre 2008 - 17:23
Hi Marco,
There is no absolute direct functions in W-Language to do this. But you can use HRetrieveRecord() and fWriteLine... this is the nearer you can go. Example:
WHILE...
fWriteLine("MyFile.csv",HRetrieveRecord(HF_File,","))
END
I never tested that, so I don't know if HRetrieveRecord handles correctly the csv spec where if the separator is found in the "string" it must be enclosed in quotes, and also escape any quotes caracters in the string.
In fact, before I knew about HRetrieveRecord I made myself a CSV export/import function.
You can also take a look at TableToText()
Regards.