question

Thijs Damsma avatar image
1 Like"
Thijs Damsma asked Matt Long commented

gettrackedvariable deprecated, is there an alternative?

According to the built in documentation, gettrackedvariable is deprecated. However, no alternative is listed. This is very unhelpful. Also settrackedvariable is not deprecated, so this seems a bit inconsistent.

I am using a tracked variable to calculate cumulative costs, like so:

	settrackedvariable("Cost", gettrackedvariable("Cost"), cost_per_time);

The cost_per_time varies, so I just want to adjust the rate, not value.

FlexSim 17.0.2
tracked variables
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

Matt Long avatar image
4 Likes"
Matt Long answered Matt Long commented

We did a lot of updates to the commands documentation and some things were overlooked or missed.

If you're trying to change the rate of a kinetic tracked variable, the current way to do that is by using the settrackedvariable() command (see the command documentation). Otherwise if you just want to set or get the value of a tracked variable, you can use .value.

For example, setting a Global Tracked Variable:

treenode cost = trackedvariable("Cost");
cost.value = cost.value + cost_per_time;

or if the tracked variable is stored on a label of a Token named myTV, the code would be:

token.myTV.value = 5;
double myValue = token.myTV.value;
· 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.

Thijs Damsma avatar image Thijs Damsma commented ·

So to adjust the rate of a kinetic variable (without changing the current value), can I then do one of the following?

settrackedvariable("Cost", trackedvariable("Cost").value, cost_per_time);
treenode cost = trackedvariable("Cost");
settrackedvariable("Cost", cost.value, cost_per_time);
1 Like 1 ·
Matt Long avatar image Matt Long Thijs Damsma commented ·

Yes, that will update the rate without changing the value.

0 Likes 0 ·