rick hart

Is there a method to index and array of a UDT?

3 posts in this topic

Hello all,   I am working with an Rockwell  1769-L18ER PLC and Studio 5000 version 32.  I am trying to setup an array of my UDT and index thru the array with a DINT.   I assumed the syntax would be something like  MyUDTArray[IndexDINT].Member but Studio 5000 indicates an error. Is there a method to index and array of a UDT? An example would be great. 

 

 Any feedback is appreciated. 

 

 

Share this post


Link to post
Share on other sites

Hard to help you...

What is the structure of the udt? What data types?  What was the code and how were you trying to use it?

I created a udt called MyUDTArray with an array of 3 Member as DINTs.  I created IndexDINT as a DINT.

I then used a compare EQU and compared MyUDTArray.Member[IndexDINT] to 0.  No issues here.

Depending on how you are planning to use the member of the udt, sometimes it's easier to copy the first instance of it from the tag database, then you'll know where to replace the array valve with IndexDINT.

To belabor the point, I then changed the tag database of MyUDTArray based upon the udt MyUDTArray from a single instances to an array of 3.

Then I had to change my reference in the EQU to MyUDTArray[IndexDINT].Member[IndexDINT], again no issues.

Edited by pcmccartney1

Share this post


Link to post
Share on other sites

In the errors window, what does Studio say the error is?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now