twincat 2-将字符划分为一系列字符串
我正在使用Twincat2进行旧项目,并从TCP连接中获得一系列字符。
示例刺痛是这样的:cmd,011,132654,38201,ABC,23
我需要将其分为单字符串。因此,基本上是一系列字符串,其中MyArray [0]为CMD,[1]是011等。
我无法弄清楚如何做到这一点。 TC3具有拆分函数,但是如何在结构化文本中在TC2中完成这件事?
谢谢
I am using Twincat2 for an old project, and get a array of chars from a TCP connection.
a sample sting is this: CMD,011,132654,38201,ABC,23
I would need to split this into single strings. So basically an array of strings, where myarray[0] is CMD, [1] is 011 etc..
I cannot figure out how to do this. TC3 has a split function, but how can this be done in TC2 in structured text?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从未使用过TC2,但这是我要解决问题的方法:
,
使用查找位置:= find(samplestring,',');
?采样,位置1);
samplestring:= delete(samplestring,位置,1);
,
在初始字符串中找到,然后将剩余的内容分配给数组的最后一个元素I have never used TC2, but here is how I would approach the problem:
,
using FINDposition := FIND(sampleString, ',');
myArray[0] := LEFT(sampleString, position-1);
,
from the initial string using DELETEsampleString := DELETE(sampleString, position, 1);
,
is found in the initial string, then assign what remains to the last element of the array