You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old June 13th, 2013, 09:24 AM   #1
rroze002
Member
United States

rroze002 is offline
 
rroze002's Avatar
 
Join Date: Jun 2013
Location: Florida
Posts: 34
COPY INT array to STRING

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.
  Reply With Quote
Old June 13th, 2013, 10:24 AM   #2
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,155
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.
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old June 13th, 2013, 10:34 AM   #3
rroze002
Member
United States

rroze002 is offline
 
rroze002's Avatar
 
Join Date: Jun 2013
Location: Florida
Posts: 34
That's exactly what it was. Thanks Bernie
  Reply With Quote
Old June 13th, 2013, 10:42 AM   #4
dmroeder
Lifetime Supporting Member
United States

dmroeder is offline
 
dmroeder's Avatar
 
Join Date: Apr 2006
Location: Vancouver, WA
Posts: 1,919
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.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Character array conversion to string tag, PB32 to FTViewME bigbuckaroo LIVE PLC Questions And Answers 4 December 6th, 2013 10:48 PM
How to Copy an Array of Strings in SLC 5/05? robertmee LIVE PLC Questions And Answers 2 April 16th, 2008 08:26 AM
Index String Array in RSLogix 5000 rta53 LIVE PLC Questions And Answers 5 April 23rd, 2007 05:47 PM
ASCII array converted to string Mike Hendrickson LIVE PLC Questions And Answers 4 April 10th, 2004 02:55 PM
Ideas needed for Siemens S7 program tesalmin LIVE PLC Questions And Answers 12 March 4th, 2004 12:40 PM


All times are GMT -5. The time now is 02:08 PM.


.