Jump to content

How to use the "Lists" feature?


Dave

Recommended Posts

Can someone help me out to understand how to use the Lists feature found in the solution explorer. I don't see anything in the help files. I can see that there are many types of Lists available, and I can easily create Lists, but I don't see where/how to actually use or reference the List(s), once created.

Link to comment
Share on other sites

  • MVP 2023

I didn't know about this one, so I went digging.  There are so many hidden nuggets in UniLogic!

There is some information about Lists in the Help under "For" Loops, specifically as an input argument in the "For Each" function block.  I couldn't find an example on them.

Any input from the Creators on how this works?

 

Joe T.

Link to comment
Share on other sites

13 minutes ago, Joe Tauser said:

I didn't know about this one, so I went digging.  There are so many hidden nuggets in UniLogic!

There is some information about Lists in the Help under "For" Loops, specifically as an input argument in the "For Each" function block.  I couldn't find an example on them.

Any input from the Creators on how this works?

 

Joe T.

You can use lists as an argument for the "for each" loop without having to manage the max iterations of a typical for loop.  Here is a quick example of the for each with a list:

image.png.a6a36ce530b3830b0aadd0fec7e20e30.png

image.png.0c7e3ed588710f95a93a930d0a40ec3e.png

 

 

Current Item tag is a local tag similar to this C example:

bool list[10]; 

int PE_Active = 0;                                         // INT16 in UniLogic

for (int index = 0, index <= MAX_INDEX; index++){

   if(list[index] == true){

         PE_Active += PE_Active + 1;

   }

}

 

 

 

Link to comment
Share on other sites

OK. thanks.

This brings up a new topic now...Combo Box list of text source

I was hoping I could utilize the "Lists" with combo boxes somehow...I would like to have the "Options: List" collection of a combo box be sourced from a dynamic list, or data table column of strings. 

Currently, the list for the combo box is fixed and can't be changed thru program code or operator entry. 

I wonder if it's possible to somehow link a data table column of strings, or a list of strings to a Combo Box or "List of Text Variable"

Link to comment
Share on other sites

Thank you @curtharrington1 for clarifying the feature.

It is indeed a new feature that was introduced, along with the "for" and "while" loops.

It is worth having a look at them!

About the feature request on the dynamic combobox, that could be a nice feature.

I'll open a feature request on it.

Have a good day!

Rivka

Link to comment
Share on other sites

  • 1 month later...
  • 9 months later...

Hi @Rivka,

Was this feature implemented on Unilogic 1.35 as the "Path (Const)" on the Combo Box properties? If so is there a way to read a specific row/column from the data table?

I've referenced the csv table in general but have just got a blank selection as I am unsure how to reference a specific row.

I'm trying to create a list of "live" recipe names in a combo box to allow the user to select a recipe to load to the PLC. 

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

Hi @MatthewO,

No, it was not implemented in 1.35. We started implementing it, and it will probably be in 1.38

However, instead of linking it to a list or a data table, the user will be able to add string tags to a dynamic combo box (just like adding texts to regular combo box), and the combo box will show the value of the string tags.

  • Upvote 1
Link to comment
Share on other sites

  • 2 weeks later...

Is there a way of using "Load from Array" or "Store in Array" functions with Lists?

It would be awesome to make a list of structs dedicated to objects (lamps, motors, belt conveyors, robot cells...). Servicing all of them would be possible with a simple For-loop instead of a For-each.

Sometimes when there's lots of objects, to save on retained memory I make two structs for an object: one containing retained settings and one containing non-retained variables for the object which are reset to zero on power-on. I do this is because I can't pick which variables in a struct will be retained, and which would not. Only the whole struct can be marked as retained. That would be a huge waste of precious retained 256K.

Problem arises when using For-each: the loop can only take ONE type of struct, not two. So the variables struct can't see the settings struct.

Link to comment
Share on other sites

  • 1 month later...
On 6/15/2024 at 2:24 PM, kvlada said:

Is there a way of using "Load from Array" or "Store in Array" functions with Lists?

It would be awesome to make a list of structs dedicated to objects (lamps, motors, belt conveyors, robot cells...). Servicing all of them would be possible with a simple For-loop instead of a For-each.

Sometimes when there's lots of objects, to save on retained memory I make two structs for an object: one containing retained settings and one containing non-retained variables for the object which are reset to zero on power-on. I do this is because I can't pick which variables in a struct will be retained, and which would not. Only the whole struct can be marked as retained. That would be a huge waste of precious retained 256K.

Problem arises when using For-each: the loop can only take ONE type of struct, not two. So the variables struct can't see the settings struct.

Hi Kvlada,

if the values that must be retained don't change really fast you can consider to save it in a file...so...you can upload the info from the file at each boot of the system...this means that an SD must be present but this will also guarantee that all info will be recover and a new PLC could run really quickly in case of replacement.

Link to comment
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
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.