How to get a substring from another string in PM573-ETH code
I’ve coded a string and want to extract the subparts like GOTO 01 or 01234 as strings
I've found string functionality in Standard.lib and aprt of the code is like this:
CMD:STRING := ’GOTO 01, 01234’;
(* code side*)
TempCMD := MID(CMD, 4,0);
TempINDEX := MID(CMD, 2,6);
How ever I don’t get the expected ”GOTO” substring nor ”01”.
Voted best answer
I think You got the first function wrong. MID(anySTRING, anyINT, 0) will return an empty string, as You should count the POSition from 1. So to get 'GOTO' You should use:
TempCMD := MID(CMD,4,1);
On the other hand TempINDEX := MID(CMD, 2,6); should work just fine. I even checked it in simulation mode and it returns TempINDEX = '01'. What did You get when running Your code? Maybe knowing output I can pinpoint where is the problem.
Hope this helps,