COPY INT array to STRING

rroze002

Member
Join Date
Jun 2013
Location
Florida
Posts
39
Hi all,

I'm trying to populate a STRING with ASCII characters from an SINT array. My COP command is setup in the following fashion:

COP(BAR_CODE_SCANNER:I.ResultData[0],Bar_code,10)

What I need is the first 10 bytes from the BAR_CODE_SCANNER:I.ResultData array to be copied into the Bar_code string so that I can keep track of it in some kind of a table. Also I want this table to be displayed on PanelView 1000+ HMI.

Any tips will be appreciated.
 
Your target for the copy would be bar_code.Data[0]

After the COP place the length (10) into bar_code.Len

A String Copy doews these two things automatically.
 
I don't think you need to do anything with the length, but it is a good way to trim off the characters. If your destination is Bar_code.DATA[0], then it will only copy the 10 elements.

I'm guessing you were probably getting your 10 bytes plus a whole bunch of other garbage right? This is because the COP command uses the destination's size to determine the amount of data to try and copy from the source. You were telling it to copy "10". The destination string is 82 bytes. So it was attempting to copy 82*10 bytes (at least that is the way I understand it)

.DATA[0] has a length of 1 byte, so by addressing to that part of the tag, the copy will copy 10 bytes. The exact amount of data that you want.
 

Similar Topics

All, i nto fully get it. I read trough some froums but not finaly make it running. so I try to ask. Hopefully anybody has the kindness to answers...
Replies
7
Views
1,168
Hello! I am completely new to PLCs, so I apologize in advance if this is a dumb question. I have a device that sends out its data as a number of...
Replies
5
Views
2,077
Hey everybody, I have a bunch of bits used for diagnostics all compiled into a couple of DINTS. I have an x-ref sheet in Excel that aligns...
Replies
8
Views
1,847
The PLC program I'm monitoring has a UDT of alarm booleans. 36 in total. What I'm trying to do is monitor a few rungs, and also monitor a possible...
Replies
3
Views
1,572
Hello I was wondering the best way to accomplish this. I have a Setpoint that controls a valve output. This Setpoint will vary through out the...
Replies
44
Views
8,568
Back
Top Bottom