Welcome! Log In Create A New Profile

Advanced

How to Convert HF to Text ?

Posted by Marco Antonio 
Marco Antonio
How to Convert HF to Text ?
September 13, 2008 06:37PM
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
Jimbo
Re: How to Convert HF to Text ?
September 13, 2008 07:14PM
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
"Roger Dunk".pcs.crosspost
Re: How to Convert HF to Text ?
September 15, 2008 11:13AM
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
>

Message forwarded from pcsoft.us.windev
Marco Antonio
Re: How to Convert HF to Text ?
September 15, 2008 01:53PM
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
Alexandre Leclerc
Re: How to Convert HF to Text ?
September 15, 2008 02:53PM
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.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: