08-02-2016 05:50 AM
08-02-2016 08:36 AM
Your first parameter of ReadLine seems to be wrong, it should be the file handle obtained by calling OpenFile, not a constant...
08-02-2016 04:17 PM
Yes ! I rectified that!
if(GetFirstFile (PathBuffer, 1, 1, 0, 0, 0, 0, fileName) == 0);
if(GetNextFile (fileName) == 0)
{ n = GetFileInfo(fileName,&size);
if (n == 0)
FmtOut("File does not exist.");
else
FmtOut("File size = %i[b0]",size);
if (FileHandle = OpenFile (fileName, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII))
{
SetCtrlVal (panelHandle3, PANEL3_FILESUCCESS, "fichier ouvert");
ReadFile (FileHandle, LineBuffer, 10000);
SetCtrlVal (panelHandle3, PANEL3_FILESUCCESS, LineBuffer);
}
CloseFile(FileHandle);
//InsertListItem (panelHandle3, PANEL3_LISTBOX, -1, fileName, 0);
}
else
MessagePopup("error","file not found !");
******************************************************************************
Now Size ==0 and LineBuffer is showing 5 random caracters !!
08-03-2016 01:15 AM
I do not know your file contents (e.g., the first two lines of your log file could be useful) nor your PathBuffer so I only can guess. For example, I do not understand the purpose of your first line
if(GetFirstFile (PathBuffer, 1, 1, 0, 0, 0, 0, fileName) == 0);
Shouldn't there be a '{' instead of your ';' ?
In any case, what you could/should do is set breakpoints to verify that your code is doing what you expect it to do; e.g., did you verify that fileName is what you expect it to be?
08-03-2016 02:18 AM
you're right I didn't give you much informations. It doesn't matter, all the files have data in them, I can see the fileName I am already using breakpoints, but what I am doubting of is what if .log files have specific libraries like .ini files ??
08-03-2016 02:37 AM
ReadLine doesn't care about file contents, it is just interested in a linefeed character
However, if you are using ini files you might want to have a look at the toolslib library inifile.fp
08-03-2016 02:59 AM
Yes I already worked with .ini files, so do you have an idea of the best way to read .log files ??
08-03-2016 03:16 AM
If it is a simple structure I would assume that your approach is fine: read one line, e.g. using ReadLine, and then scan this line using scanning functions such as sscanf or Scan to extract its contents
08-03-2016 03:34 AM
Ok thank you, I will try that 🙂