CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Fri Oct 18, 2019 2:58 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: File Access Problem
PostPosted: Thu Oct 24, 2013 1:57 pm 
Offline

Joined: Mon Jul 16, 2012 9:11 am
Posts: 75
I meet a problem when I use the File Access 3.4.1.0 library to operate file access.
fbFileOpen:FILE_ACCESS.FILE.Open;
fbFileOpen(xExecute:=TRUE,sFileName:=strFileName,eFileMode:=FILE_ACCESS.FILE.MODE.MWRITE,xExclusive:=FALSE);
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!


Top
   
 Post subject: Re: File Access Problem
PostPosted: Fri Oct 25, 2013 3:24 pm 
Offline

Joined: Mon Jul 16, 2012 9:11 am
Posts: 75
I have just download the CoDeSys Examples of “FileUtilities”,that writes as:

IF xInit THEN
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);
END_IF
...

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!


Top
   
 Post subject: Re: File Access Problem
PostPosted: Tue Oct 29, 2013 9:14 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Tue Jun 06, 2006 9:03 am
Posts: 410
As I understand it correctly, what you say is in both cases the same.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited