question

Gui Vaccaro avatar image
0 Likes"
Gui Vaccaro asked Gui Vaccaro commented

Dot syntax failing with tracked-variable labels

Hello,

from examples and answers from the forum (e.g. https://answers.flexsim.com/questions/80701/graph-multiple-data-of-a-tracked-variable-in-one-c.html, https://answers.flexsim.com/questions/177837/performance-measure-from-tracked-variable.html) the following syntax should work to update tracked-variable labels:

myObject.myLabel = newValue;

or

myObject.myLabel.as(TrackedVariable).value = newValue;

However, as one can see below, the only working syntax is using the "labels" format:

myObject.labels["myLabel"].as(TrackedVariable).value = newValue;

1745479772533.png

It also fails when reading the variable content:

1745479995726.png

FlexSim 25.1.1
statistic collectortracked variablevalue
1745479772533.png (33.9 KiB)
1745479995726.png (122.0 KiB)
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
1 Like"
Felix Möhlmann answered Gui Vaccaro commented

Both examples you linked use Tracked Variables from the toolbox and the references point to the node in both cases, making it possible to cast the reference as TR and read the property.

1745484873257.png

1745484906368.png

Using object.labelName gets the value of the TR-node, a number, which can not be cast as a TR. You do in fact have to use the object.labels["labelName"] syntax to get the TR/Label-node and access properties of the TR.


1745484873257.png (53.4 KiB)
1745484906368.png (13.8 KiB)
· 1
5 |100000

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

Hi, @Felix Möhlmann , thank you.

You are correct on your interpretation. My observation is about the incorrect syntax used in the previous answers from FlexSim. I could not find any explicit reference about this in the help files.

Thank you for the confirmation.

0 Likes 0 ·