FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Get the contents of an Ascii file (.Txt or .htm) to a Variab
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Get the contents of an Ascii file (.Txt or .htm) to a Variab
Posted: Thu Apr 09, 2009 08:22 AM

Hi,

How to get the contents of an Ascii file (.Txt or .htm) to a Variable

For Eg: I need to open a .Txt file .or. .html (basically ascii files) and read its contents to a memory variable. I would like to know the right function to get this done with a sample.

Thanks & Regards

Anser

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab
Posted: Thu Apr 09, 2009 08:53 AM

I think I got it. It can be done using cVar:=MemoRead(cFileName). Hope I am on the right direction. I don't know whether there are any other better solution than this MemoRead()
Regards
Anser

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab
Posted: Thu Apr 09, 2009 09:32 AM

Anser,

MemoRead() is the easiest and simplest way :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab
Posted: Thu Apr 09, 2009 10:49 AM

Thankyou Mr.Antonio

Regards

Anser

Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab
Posted: Thu Apr 09, 2009 10:58 AM

It is also possible with TTEXT class .
oTxt:=TTxtFile():New("test.txt")
wnbl:=oTxt:recCount()
for bcl=1 to nbl
aadd(vtxt,oTxt:ReadLine())
oTxt:skip()
next
oTxt:end()
*

It is also possible to create a temporary dbf file with long text field
and then do : APPEND FROM "test.txt" SDF

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab
Posted: Thu Apr 09, 2009 11:19 AM

Thankyou Mr.Jack :)

Regards

Anser

Continue the discussion