PDA

View Full Version : Index String Array in RSLogix 5000


rta53
April 23rd, 2007, 11:52 AM
I would appreciate some help with how to index a string array in RSLogix 5000 v16. I have to create a date and time string but the month has to be in the format of Jan, Feb, etc. I created an array tag I called month_array with 13 elements. I used 13 so I could equate 1 to 12 with Jan to Dec. I will use a compare instruction such as date_month = 4, then index the array to Apr. How do I do this?

Peter Laing
April 23rd, 2007, 01:30 PM
Use a DINT tag for the index.
Use the COP instruction as shown in the attached screen capture.
Cheers,
PL

Mark Buskell
April 23rd, 2007, 01:36 PM
Will you be sending this to a PanelView Plus.
If so and you can use structured text, look at this program.
If takes the WALLCLOCKTIME and formats it and places the result
in SDateTime in the form of Mar. 07, 2007, 02:47:35 P.M.
You will have to modify to fit your needs.

I didn't write the original but modified this version to fit my needs.

Mark Buskell
April 23rd, 2007, 01:56 PM
Also, if you just want it local, use a
COP function.
Copy StringConst[test4] to stringtest with a length of 1.
test4 is a DINT, I put a 4 in it and it then copied Apr. to
my stringtest.

curlyandshemp
April 23rd, 2007, 02:28 PM
I would appreciate some help with how to index a string array in RSLogix 5000 v16. I have to create a date and time string but the month has to be in the format of Jan, Feb, etc. I created an array tag I called month_array with 13 elements. I used 13 so I could equate 1 to 12 with Jan to Dec. I will use a compare instruction such as date_month = 4, then index the array to Apr. How do I do this?




Clock[1] contains the month #
Month[] is a string array of Month text,
Month[1]= "Jan"
Month[2]= "Feb", etc

http://www.plctalk.net/qanda/uploads/month_index_1.jpg

rta53
April 23rd, 2007, 05:47 PM
Thanks for all the help. I have gotten most of this figured out but my problem now is how to format the date/time in the way the customer wants it. This is what they told me they want:

System1_23-Apr-07093008 which is 2007-9:30:08 AM

I can do the part up to the year with no problem. I shortened 2007 to 07 by using the string DELETE instruction. I can change the month. The problem now is how to deal with adding in the zeros when the hours and minutes are less than 10 and then removing them when the hours and minutes are greater than 9. I tried using the INSERT instruction but that just creates a mess. Hopefully I can leave off the seconds. What's the best way to do this? I have to do it in ladder.