i try to write data in a file text without succes.
I use the CAA_File library.
First problem, I never get the position at the end of the file.
I know the handling of the files is asynchronous, so I put a timeout between fileof and filwr to make sure the return from fileof.xDone and fileof.xEOF is done correctly.
If xEOF is false, I increment the position by one and execute filsp (setPosition) and retest fileof (xExecute: = TRUE)
However my pointer position index increases to values exceeding thousands when there are less than 10 characters.
I have to write a file of three lines and twenty-one columns from an array of variables (nothing complicated there to loop).
The loop work as:
1 - getPosition
2 - test if xEOF
3 - If not xEOF then iPosition++, setPosition and back to test xEOF.
4 - If xEOF then write the data[i] in the text file and back to getPosition for pprocess the data[i+1]
5 - i and j = maxCounter then filcl
I can't find the right way to do this with filgp, fileof, and filsp.
Would you like to explain to me how and how fileof works?
Thanks.
I do not know the answer to your problem. For me though, I think the CAA File is still very low level and difficult to get right. If you want to save yourself some hassle, use the CSV Utils SL library.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everybody,
i try to write data in a file text without succes.
I use the CAA_File library.
First problem, I never get the position at the end of the file.
I know the handling of the files is asynchronous, so I put a timeout between fileof and filwr to make sure the return from fileof.xDone and fileof.xEOF is done correctly.
If xEOF is false, I increment the position by one and execute filsp (setPosition) and retest fileof (xExecute: = TRUE)
However my pointer position index increases to values exceeding thousands when there are less than 10 characters.
I have to write a file of three lines and twenty-one columns from an array of variables (nothing complicated there to loop).
The loop work as:
1 - getPosition
2 - test if xEOF
3 - If not xEOF then iPosition++, setPosition and back to test xEOF.
4 - If xEOF then write the data[i] in the text file and back to getPosition for pprocess the data[i+1]
5 - i and j = maxCounter then filcl
I can't find the right way to do this with filgp, fileof, and filsp.
Would you like to explain to me how and how fileof works?
Thanks.
Last edit: julien 2021-03-10
I do not know the answer to your problem. For me though, I think the CAA File is still very low level and difficult to get right. If you want to save yourself some hassle, use the CSV Utils SL library.