ST Help with String INSERT

_Dock_

Member
Join Date
Sep 2015
Location
KY
Posts
508
I'm new to ST so go easy.

Studio 5000
L33ER PLC

I'm trying to take 2 strings, merge them into 1 string. with a space between the 2 strings.

this works in ladder just fine.

However this code in ST does not work.

if
ST_RUN
then;

DTOS(Material_ID[1],Material_IDString[1]);
INSERT(Material_IDString[1],space,3,MatIDPlus[1]);
CONCAT(MatIDPlus[1],Material_Description[1],HMI_Mat_List_Display[1]);
CONCAT(MatIDHMI,HMI_Mat_List_Display[1],CI_MaterialStrings[1]);

If I change the Material_ID, the DTOS works
Material_IDString is valid and correct
The INSERT instruction with the Space is the problem, after the Space, the MatIDPlus remains the same of the old Material_IDString

The space String tag is " ", the insert function writes the " " to start at bit 3.

String Merge 1.JPG ST Example.JPG
 
Last edited:
Well here you go, the second you reach out for help you figrue it out.

MaterialID, was 2 digits, I had the space written to bit 4 instead of bit 3.

It works now...

Its late and im tired!
 
I guess ill add that I still don't understand why the the MatIDPlus wouldnt get the correct value.

You would think it would read "MatID # 40D escrtiption"

All the while still updating the material ID number regardless of where the space is. I guess because there was a valid character in its place?
 
Last edited:
You would think it would read "MatID # 40D escrtiption"


Actually, I would not think that, because at the time of the INSERT call, the source string argument (e.g. Source A here) is "40" and the string "Description" has not been concatenated yet.

Also at that link, it notes that the position argument, Start, should be between 1 and the DATA size of the source, the latter is 2 in this case. Later it states that a fault should be thrown if Start is greater than the DATA size. Apparently those are typos in that Rockwell manual, as it works with DATA size + 1.

Finally, inserting a space at (i.e. after) the end of a string (Start = 3 = 2 + 1 for the 2-character Source A string "40") should be the same as concatenating a space to a string, so using CONCAT would make the code robust to input strings of lengths other than 2 e.g.

  • "0"
  • "9"
  • "140"
  • "-40"
  • etc.
 

Similar Topics

Hi, I'm new with ST and especially data structures and I am trying to create a data structure to store the following shapes and properties...
Replies
0
Views
592
I have a Horner PLC that is reading Ascii string from a device. When the device responds, it responds with the hex value in Ascii. I need to...
Replies
8
Views
2,382
hi, i try to capture barcode data using UDT with SINT ascii array. i have all the data i need but it in array format, how can i convert to 1...
Replies
5
Views
3,058
Hello all, I am stumped about how to validate an expression in order to meeting the following conditions. Here's what I want to do: I have a...
Replies
4
Views
2,825
Could somebody please point me in the right direction? I'm trying to incorporate a table into each motor's faceplate. It's a simple, two...
Replies
2
Views
3,202
Back
Top Bottom