Get the contents of an Ascii file (.Txt or .htm) to a Variab

Get the contents of an Ascii file (.Txt or .htm) to a Variab

Postby anserkk » Thu Apr 09, 2009 8: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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab

Postby anserkk » Thu Apr 09, 2009 8: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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab

Postby Antonio Linares » Thu Apr 09, 2009 9:32 am

Anser,

MemoRead() is the easiest and simplest way :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab

Postby anserkk » Thu Apr 09, 2009 10:49 am

Thankyou Mr.Antonio

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab

Postby Jack » 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
Jack
 
Posts: 288
Joined: Wed Jul 11, 2007 11:06 am

Re: Get the contents of an Ascii file (.Txt or .htm) to a Variab

Postby anserkk » Thu Apr 09, 2009 11:19 am

Thankyou Mr.Jack :)

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests