FOR n:=1 TO 255 DO
CONCAT2(pSrcString1:=ADR(GlobalPersistent.ReadAllEvents[n].sDate),pSrcString2:=ADR(GlobalPersistent.ReadAllEvents[n].STime),pDstString:=ADR(GVariable.WriteToFileString[n]),nDstSize:=255);
formatStrg:='%s,%s,%s,%s';
FBFormatString(sFormat:=FormatStrg, arg1:=FSTRING(GlobalPersistent.ReadAllEvents[n].sDate),
arg2:=FSTRING(GlobalPersistent.ReadAllEvents[n].STime),
arg3:=FSTRING(GlobalPersistent.ReadAllEvents[n].sSource),
arg4:=FSTRING(GlobalPersistent.ReadAllEvents[n].sMessageText),
sOut=>GVariable.WriteToFileString[n]);
ENDFOR
I string write to array, when this Array I write to txt file
fbFileWrite( bExecute := FALSE );
fbFileWrite( sNetId:=sDestNetId, hFile:=hDestFile,
pWriteBuff:= ADR(GVariable.WriteToFileString), cbWriteLen:= SIZEOF(GVariable.WriteToFileString),
bExecute:=TRUE, tTimeout:=tTimeOut );
I open create file and see this. I attached picture
Maybe you should not use SIZEOF, but LEN. Because SIZEOF means you will get the memory size of your string variable (e.g. maximum 80 characters), but LEN will give the actual length of the string.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In addition to the above tip, your program is overlooking error codes for formatting and file access functions; it is always good practice to read these parameters.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I have variable code:
FOR n:=1 TO 255 DO
CONCAT2(pSrcString1:=ADR(GlobalPersistent.ReadAllEvents[n].sDate),pSrcString2:=ADR(GlobalPersistent.ReadAllEvents[n].STime),pDstString:=ADR(GVariable.WriteToFileString[n]),nDstSize:=255);
formatStrg:='%s,%s,%s,%s';
FBFormatString(sFormat:=FormatStrg, arg1:=FSTRING(GlobalPersistent.ReadAllEvents[n].sDate),
arg2:=FSTRING(GlobalPersistent.ReadAllEvents[n].STime),
arg3:=FSTRING(GlobalPersistent.ReadAllEvents[n].sSource),
arg4:=FSTRING(GlobalPersistent.ReadAllEvents[n].sMessageText),
sOut=>GVariable.WriteToFileString[n]);
ENDFOR
I string write to array, when this Array I write to txt file
fbFileWrite( bExecute := FALSE );
fbFileWrite( sNetId:=sDestNetId, hFile:=hDestFile,
pWriteBuff:= ADR(GVariable.WriteToFileString), cbWriteLen:= SIZEOF(GVariable.WriteToFileString),
bExecute:=TRUE, tTimeout:=tTimeOut );
I open create file and see this. I attached picture
Maybe you should not use SIZEOF, but LEN. Because SIZEOF means you will get the memory size of your string variable (e.g. maximum 80 characters), but LEN will give the actual length of the string.
In addition to the above tip, your program is overlooking error codes for formatting and file access functions; it is always good practice to read these parameters.