FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Text File (SOLVED)
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Text File (SOLVED)
Posted: Tue May 30, 2017 11:57 PM
I have a text file the when opened with Notepad, all the data is strung together.
If I open the same file with UltraEdit it asks me "Do you want to convert test.asc to DOS format"
When I answer "yes" the data is separated into individual lines. This is what I am looking to get via code.

Does anyone know how I can do this conversion?
I want to be able to grab data via MemoLine() to get to the data I need.

Here is a sample of the text file (.asc) if anyone needs to see what I'm tallking about;
http://www.can-soft.net/dlnew/test.asc
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Text File
Posted: Wed May 31, 2017 06:58 AM
In this file the end of line is a chr(10) and not a chr(13) + chr(10).
You can read it in this way.

Code (fw): Select all Collapse
filename = "test.asc"

handle = fopen(filename)
stringa = space(500)
fread(handle, @stringa, 200)
if chr(13) + chr(10) $ stringa
    end_of_line = chr(13) + chr(10)
else
    if chr(13) $ stringa
        end_of_line = chr(13)
    else
        end_of_line = chr(10)
   endif
endif
fclose(handle)

handle = fopen(filename)
do while .t.
      stringa = space(500)
      if hb_freadline(handle, @stringa, { end_of_line },500 ) < 0
          exit
      endif

      //process stringa here

enddo
fclose(handle)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Text File
Posted: Wed May 31, 2017 10:25 AM
Code (fw): Select all Collapse
cText := memoread( cfile )
cText := StrTran( StrTran( cText, CRLF, Chr(10) ), Chr(10), CRLF )
MEMOWRIT( cFile, cText
Regards



G. N. Rao.

Hyderabad, India
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Text File (SOLVED)
Posted: Wed May 31, 2017 12:15 PM

Thank you. Works perfectly now :)

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)

Continue the discussion