filrd.szSize is always read as zero, I am wondering why this is happening.
Also I am confused about what the how the pBuffer in filrd works. when I set the pBuffer to "" it is the a number 22 greater than the pBuffer for the initial write.
Any help with this issue would be appreciated thanks.
(* example of how to use the CAA_FILE-library - file standard function blocks *)PROGRAMPLC_PRGVAR  xFileStdInit:  BOOL:=FALSE;  uiFileStdState:UINT:=0;  sFileName: CAA.FILENAME:='/home/pi/TestDirectory/newtester3.txt';  hFile:   CAA.HANDLE;  sFileTestString:  STRING:='HelloCAAlibraryuser';  sFileString:  STRING:='';  szFileSize1:  CAA.SIZE:=0;  szFileSize2:  CAA.SIZE:=0;  filop:   FILE.Open;  filwr:   FILE.Write;  filrd:   FILE.Read;  filcl:   FILE.Close;  END_VARIFNOTxFileStdInitTHEN  filop(xExecute:=FALSE);  filcl(xExecute:=FALSE);  filwr(xExecute:=FALSE);  filrd(xExecute:=FALSE);  xFileStdInit:=TRUE;  uiFileStdState:=0;ELSE  CASEuiFileStdStateOF  0:(* create a new file *)    filop.sFileName:=sFileName;    filop.eFileMode:=FILE.MODE.MRDWR;    filop.xExclusive:=FALSE;    filop(xExecute:=TRUE);    IFfilop.xDoneTHEN      hFile:=filop.hFile;      uiFileStdState:=1;    END_IF    IFfilop.xErrorTHEN      (* error handling*)      ;    END_IF  1:(* write text in the file *)    filwr.hFile:=hFile;    filwr.pBuffer:=ADR(sFileTestString);    szFileSize1:=INT_TO_UINT(STANDARD.LEN(sFileTestString));    filwr.szSize:=szFileSize1;    filwr.udiTimeOut:=100000;    (* 100ms Timeout *)    filwr(xExecute:=TRUE);    IFfilwr.xDoneTHEN      uiFileStdState:=2;    END_IF    IFfilwr.xErrorTHEN      (* error handling*)      ;    END_IF  2:(* read file - TestFile.txt*)    filrd.hFile:=hFile;    filrd.udiTimeOut:=100000;    (* 100ms Timeout *)    filrd.pBuffer:=ADR(sFileString);    filrd.szBuffer:=255;    filrd(xExecute:=TRUE);    IFfilrd.xDoneTHEN      szFileSize2:=filrd.szSize;      IFszFileSize2=szFileSize1THEN        uiFileStdState:=3;      ELSE        (* error handling*)        ;      END_IF    END_IF    IFfilrd.xErrorTHEN      (* error handling*)      ;    END_IF  3: (* close file - TestFile.txt *)    filcl.hFile:=hFile;    filcl(xExecute:=TRUE);    IFfilcl.xDoneTHEN      uiFileStdState:=4;    END_IF    IFfilcl.xErrorTHEN      (* error handling*)      ;    END_IF  4: (* end of example *)        ;  END_CASEEND_IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
filrd.szSize is always read as zero, I am wondering why this is happening.
Also I am confused about what the how the pBuffer in filrd works. when I set the pBuffer to "" it is the a number 22 greater than the pBuffer for the initial write.
Any help with this issue would be appreciated thanks.