Join us today!
Notifications
Clear all
twincat string
Topic starter
Jul 31, 2023 12:40 pm
(@sarunas-z)
Active Member
Joined: 1 year ago
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:=F_STRING(GlobalPersistent.ReadAllEvents[n].sDate), arg2:=F_STRING(GlobalPersistent.ReadAllEvents[n].STime), arg3:=F_STRING(GlobalPersistent.ReadAllEvents[n].sSource), arg4:=F_STRING(GlobalPersistent.ReadAllEvents[n].sMessageText), sOut=>GVariable.WriteToFileString[n]); END_FOR
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
how solve problem don't show a lot of NULL
This topic was modified 1 year ago by Sarunas.Z
Reply
1 Reply
Aug 01, 2023 7:56 am
(@kolyur)
Active Member
Joined: 2 years ago
I would guess the problem is how you are executing fbFileWrite. If this is cyclical ST code, you shouldn't execute the function block twice in the same scan. Your code is continually toggling the bExecute bit which could explain the result you're seeing. A common practice is to monitor the bBusy bit after executing fbFileWrite with bExecute:=true. It isn't necessary to turn off bExecute until the busy bit goes false.
Reply
Forum Information
- 17 Forums
- 265 Topics
- 932 Posts
- 2 Online
- 688 Members
Our newest member: fink123
Forum Icons:
Forum contains no unread posts
Forum contains unread posts
Topic Icons:
Not Replied
Replied
Active
Hot
Sticky
Unapproved
Solved
Private
Closed