Hi, I read the documentation for CAA File library but it's not up to date; I wrote a fix, and it's compiling but File.Open.xError is true and the file isnt written nor opened nor created.
The code i used was:
FUNCTIONFile_Handle:BOOLVAR_INPUTÂ Â n:STRING(255);Â Â str:STRING(255);Â Â END_VARVARÂ Â err:BOOL:=FALSE;Â Â filop:Â Â Â FILE.Open;Â Â filwr:Â Â Â FILE.Write;Â Â filrd:Â Â Â FILE.Read;Â Â filcl:Â Â Â FILE.Close;Â Â Â Â sFileName:Â STRING(255):='TestFile.txt';Â Â hFile:Â Â Â DWORD;Â Â Â Â sFileString:Â Â STRING:='';Â Â szFileSize1:Â Â UINT:=0;Â Â szFileSize2:Â Â UINT:=0;END_VAR
(* create a new file *)Â Â Â Â filop.sFileName:=n;Â Â Â Â filop.eFileMode:=FILE.MODE.MWRITE;Â Â Â Â filop.xExclusive:=FALSE;Â Â Â Â filop(xExecute:=TRUE);Â Â Â Â IFfilop.xDoneTHENÂ Â Â Â Â Â hFile:=filop.hFile;Â Â Â Â END_IFÂ Â Â Â IFfilop.xErrorTHENÂ Â Â Â Â Â (* error handling*)Â Â Â Â Â Â err:=TRUE;Â Â Â Â ELSEÂ Â Â Â Â Â err:=FALSE;Â Â Â Â END_IFÂ Â Â Â Â Â Â Â (* write text in the file *)Â Â Â Â filwr.hFile:=hFile;Â Â Â Â filwr.pBuffer:=ADR(str);Â Â Â Â szFileSize1:=SIZEOF(str);Â Â Â Â filwr.szSize:=szFileSize1;Â Â Â Â filwr.udiTimeOut:=100000;Â Â Â Â (* 100ms Timeout *)Â Â Â Â filwr(xExecute:=TRUE);Â Â Â Â IFfilwr.xDoneTHENÂ Â Â Â Â Â ;Â Â Â Â END_IFÂ Â Â Â IFfilwr.xErrorTHENÂ Â Â Â Â Â (* error handling*)Â Â Â Â Â Â err:=TRUE;Â Â Â Â ELSEÂ Â Â Â Â Â err:=FALSE;Â Â Â Â END_IFÂ Â Â Â Â Â Â Â File_Handle:=err;
Do you have any solution? ty
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I read the documentation for CAA File library but it's not up to date; I wrote a fix, and it's compiling but File.Open.xError is true and the file isnt written nor opened nor created.
The code i used was:
//------------------------------------------------------------------------------------------------------------//
Do you have any solution? ty
It doesnt works because you are creating file objects inside a function. Everytime you call the function the objects are redefined.
Execute has to pass from false to true.
Be carefull in call file objects from inside realtime, its blocks the realtime.
Sent from my Moto G (5S) Plus using Tapatalk
why the read function block doesn't have an output string???
Do you have any solution? ty