It is advisable to use the CAA_FILE.library.
In the help of V3 is an example.
Libraries > System Libraries > CAA Libraries > CAA_FILE.library > Examples > File - Standard (EXAMPLE)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Below you can find the copy from the help. I didn't test this and have no idea whether it works directly without compile errors.
You should off course also add the USE CASE library "File access".
Please also check the store at http://store.codesys.com. After signing in you can download a package with a "File Utilities" example.
Hello - from a new user!
I have integrated the relevant statements from the "official" example for opening a file with the CAA File library. The statement "filop.eFileMode:=FILE.MRDWR" produces an error (in a German language system):
The tooltip on ".eFileMode" shows me:
When I use this file mode value "FILE_MWRRD, the same error - with this sentence - will be shown.
Where is my mistake - I have no idea?!
System: CODESYS V3.5 SP2 Patch 2 on a Windows 7 system.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
[PLEASE] I'm newbie in PLC programming, I can't update my value of string when I'm changing text in txtfile while the programming is logging and running.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
TimvH hat geschrieben:
It is advisable to use the CAA_FILE.library.
In the help of V3 is an example.
Libraries > System Libraries > CAA Libraries > CAA_FILE.library > Examples > File - Standard (EXAMPLE)
I have used The same Example and its Working but the .txt File is not human readable Format .
And also i have taken DINT Array in sFileTestString.
How can i save file with Proper Format.
declare string type
sFileTestString : string(500);
cnt : int := 500;
assign the integer into string;
sFileTestString := int_to_string(int);
then in the file write function the buffer is point to the string.
filwr.pBuffer:=ADR(sFileTestString);
By this way you can get human readable data. To store all the data type into human readable you need to convert it into string, and this is very painful job to do.
Thank you
John Lee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Can you please provide me a working sample code for Write and Read File using Codesys v3 ?
Thanks,
Naganatha Subramanian R
Did you solve that?
It is advisable to use the CAA_FILE.library.
In the help of V3 is an example.
Libraries > System Libraries > CAA Libraries > CAA_FILE.library > Examples > File - Standard (EXAMPLE)
old post
Thank you so much for the answer.
I don't have the example, can you send me it?
Is it possible to attacc in a post?
Thank you again!
Below you can find the copy from the help. I didn't test this and have no idea whether it works directly without compile errors.
You should off course also add the USE CASE library "File access".
Please also check the store at http://store.codesys.com. After signing in you can download a package with a "File Utilities" example.
Thank you so much!
I will test it!
Hello - from a new user!
I have integrated the relevant statements from the "official" example for opening a file with the CAA File library. The statement "filop.eFileMode:=FILE.MRDWR" produces an error (in a German language system):
The tooltip on ".eFileMode" shows me:
When I use this file mode value "FILE_MWRRD, the same error - with this sentence - will be shown.
Where is my mistake - I have no idea?!
System: CODESYS V3.5 SP2 Patch 2 on a Windows 7 system.
The example is from a somewhat older library.
You should now use:
filop.eFileMode:=file.MODE.MRDWR;
Hello TinvH,
thank you - this is the solution that works! 3S has some problems with its online help maintenance.
With regards, Rudolf.
thank you so much it was helpful for me too
[PLEASE] I'm newbie in PLC programming, I can't update my value of string when I'm changing text in txtfile while the programming is logging and running.
I have used The same Example and its Working but the .txt File is not human readable Format .
And also i have taken DINT Array in sFileTestString.
How can i save file with Proper Format.
receipe.txt [403 Bytes]
Hi Anu,
declare string type
sFileTestString : string(500);
cnt : int := 500;
assign the integer into string;
sFileTestString := int_to_string(int);
then in the file write function the buffer is point to the string.
filwr.pBuffer:=ADR(sFileTestString);
By this way you can get human readable data. To store all the data type into human readable you need to convert it into string, and this is very painful job to do.
Thank you
John Lee