PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 2024 → LF (Linefeed)
LF (Linefeed)
Iniciado por Antonino Neri, set., 08 2010 5:56 PM - 3 respostas
Publicado em setembro, 08 2010 - 5:56 PM
Hello everyone!

I need to handle an external file (output of a UNIX system) that uses the LF character as separator. When I use the fOpen function it correctly opens the file but reads only one string without CRs. The same thing happens if I open the file using the notepad. Instead if I open the file using Ultraedit everything shows the way it should.

I need WinDev 15 to handle this file as Ultraedit does. How can I do that?


Kindest Regards,
Antonino Neri
Publicado em novembro, 07 2011 - 9:37 AM
I know this is an old post question, but I faced the same issue and found a solution I thought I'd share.

When reading unix files like a syslog file, I did a fReadLine. This actually reads the whole file since their is no CRLF to separate. The solution is to then do an ExtractString on Charact(10) [LineFeed], to get the lines of the unix file. Here is the code I used.

First I count the number of LF and then just do a loop to read the lines into a HF table.


nTmpfileid is int = fOpen(sTmpFileDirName)
IF nTmpfileid > 0 THEN
sTmpline = fReadLine(nTmpfileid)
nTmpCount is int = StringCount(sTmpline,Charact(10))
IF nTmpCount > 0 THEN
FOR i=1 TO nTmpCount
sTmpLine2 = ExtractString(sTmpline,i,Charact(10))
HReset(syslog_messages)
syslog_messages.syslogmessage = sTmpLine2
syslog_messages.syslog_filename = sInfilename
syslog_messages.syslog_source = sInFilesource
HAdd(syslog_messages)
END
END
fClose(nTmpfileid)
END


Hope this helps someone.
Publicado em novembro, 07 2011 - 5:51 PM
Thanks for sharing Stephen!

This is very useful.


Cheers
Publicado em setembro, 02 2020 - 8:48 PM
Dude thanks for your answer 9 Years later...
It was headhache on my side.