question

Jarek O avatar image
0 Likes"
Jarek O asked Ralf Gruber commented

How to group labels?

Hi all,

Imagine you have a lot of labels that connects catnames to their ages. I want to have these labels grouped in a "superlabel" called Cat_Ages. For example I assign a label to token.Cat_Ages called "Garfield" with value 5.

When I try this I get exception Error: Invalid assign to reference. although the label token.Cat_Ages does exist.

FlexSim 17.1.1
labels
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Matt Long avatar image
2 Likes"
Matt Long answered Ralf Gruber commented

Labels can't have their own labels. Objects and tokens store labels. If you want a label that stores more information you can either use an array as Sam suggested (though that will not give you two values, the name and the age) or you can use subnodes on the label. A third option would be to have your Cat_Ages label actually be a reference to another token. You could create a dummy token that you use just for storing labels on. Then you can use straight dot syntax to get and set those values.

token.Cat_Ages.Garfield

Attached is a simple model showing this done.

catages.fsm


catages.fsm (15.0 KiB)
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jarek O avatar image Jarek O commented ·

Thanks for the answers @Sam Stubbs and @Matt Long.

The dummy toke suggestion is the most useful solution to what I'm thinking of. I was asking this question for future issues where tokens have an unacceptable number of labels...

Thank you,

Jarek

0 Likes 0 ·
Ralf Gruber avatar image Ralf Gruber ♦ Jarek O commented ·

Jarek,

in that case you might want to have all the information stored in a global table and have a token label with just a reference to the table information.

The other option would be to have the token reference a label on a 3D dummy object. Labels on 3D objects or FlowItems can have bundle data, allowing you to create a table in a label.

Best wishes

Ralf

2 Likes 2 ·
Sam Stubbs avatar image
1 Like"
Sam Stubbs answered

I'm not exactly sure I follow what you're trying to do. IF you want a label that has a reference to a lot of other labels, you'll need to set it as an array. A label array can be a list of references to other labels.

One of the most common ways people use label arrays is when pushing/pulling from a list. If you pull a number of items from a list, you can store references to them all in a label array.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.