CODESYS - the IEC 61131-3 automation software

File Access Problem
Page 1 of 1

Author:  yue_qi_qi [ Thu Oct 24, 2013 1:57 pm ]
Post subject:  File Access Problem

I meet a problem when I use the File Access library to operate file access.
after fbFileOpen() executed,the content of the file that the function block open will be cleard! And the size of the file will be 0!

Author:  yue_qi_qi [ Fri Oct 25, 2013 3:24 pm ]
Post subject:  Re: File Access Problem

I have just download the CoDeSys Examples of “FileUtilities”,that writes as:

CASE iState OF
0: //Open the specified file with write access.
FileOpen(xExecute:= TRUE, sFileName:= sFileName, xExclusive:= FALSE, eFileMode:= File.MODE.MWRITE );
IF FileOpen.xDone = TRUE THEN
iState := 1;
hfile := FileOpen.hFile;
FileOpen(xExecute:= FALSE);
ELSIF FileOpen.xError = TRUE THEN
iState:= 32767;
FileOpen(xExecute:= FALSE);

The code above is tested on CoDeSys Control Win V3, and if there has exist a file which the sFileName specifies, and the file size is not 0, but after the above FileOpen() function executed and success with xFone=TRUE.the file size is 0, which means the file which is open with File.MODE.MWRITE mode will be cleared to empty!
In my mind, if you open the file with File.MODE.MWRITE, if the file does not exists, the file will be created and opened;and if the file has existed, then the file will be opened and should be cleared to empty!
But the test above shows that open a file with File.MODE.MWRITE mode means create a new file or clear an existing file to empty!

Author:  TimvH [ Tue Oct 29, 2013 9:14 pm ]
Post subject:  Re: File Access Problem

As I understand it correctly, what you say is in both cases the same.

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited