TwinCAT 4 SPLIT STRING

Vijolica555

Level-1
Beiträge
23
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
TwinCAT 3 SPLIT STRING

Hello guys,

I am new at forum. My German knowledge is so so, I will ask my question in English and I hope smb will be willing to help :)

I am using TwinCAT 3.
I am having string: 'OK;FFT;1.0;8.0$NX;0.0001;0.375;0.0053;3.5$NY;0.0001;0.375;0.0053;3.5$NZ;0.0001;0.375;0.0053;3.5$NV;0.0003;1.125;0.0161;3.5($R' and I would like to split it at 5 string, after every $N.
Example:
'OK;FFT;1.0;8.0$N
X;0.0001;0.375;0.0053;3.5$N
Y;0.0001;0.375;0.0053;3.5$N
Z;0.0001;0.375;0.0053;3.5$N
V;0.0003;1.125;0.0161;3.5($R'

I tried some things but did not succeed. Does anybody have any suggestion maybe? Is there any Fb or function in TwinCAT that I did not found?

(Later I would like to read every data in string separately but I assume I can delate $N and $R and wrote it to the Array, or?).

Thank you.
 
Zuletzt bearbeitet:
Zuviel Werbung?
-> Hier kostenlos registrieren
Hello,
Thank youfor your reply. I looked into String functions, I am also using them, but asfar as I know how to use them they are made to pick position of the part youwant to delete, ect… But my position is not always the same.. measurements aredifferent so is the length of the string.
 
No, that's wrong, you can use these commands also if you don't know the exact position.
In your case you have to look for the $N with the function FIND, then you copy the first entry to another string with LEFT, the entry for size will be the return value of FIND - 1. After that you delete the first entry including the $N from the original string with DELETE, POS will be 1 and LEN the return value of FIND. Then continue with the second entry and so on.
 
Zuletzt bearbeitet:
Zurück
Oben