question

Martin K6 avatar image
0 Likes"
Martin K6 asked Felix Möhlmann answered

How to check if specific label on token exists?

Hello,


I woul like to ask if it is possible to check if specific label on token exists or not?


Thank you.

FlexSim 22.1.3
tokenexist
5 |100000

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

1 Answer

Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered

token.labelName? will return NULL if the label does not exist and the value of the label if it does. Note that there is no difference in the return value between a label that does not exist and an empty pointer label.

Similar to that is using token.labels.assert("labelName", initValue).value. This checks if the label exists. If it does, it returns the value. If not, it creates the label and sets its value to 'initValue' and returns that.

Lastly, if you are not interested in the value of the label (if it exists), you can use objectexists(token.labels["labelName"]). This checks if a label node with the given name exists and returns either 1 (true) or 0 (false).

5 |100000

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