question

G. Moser avatar image
0 Likes"
G. Moser asked Jeanette F commented

Use of tracked variables in an instanced sub flow create an error

I wanted to create an instanced sub flow that access to a different tracked variable for each instance (Instance 1 access to TV_1 and Instance 2 access to TV_2).


1715689103511.png

To achieve that I have written a code to link the “Variable” activity to the correct tracked variable in the “Variable of Value” formular and put the type as local (to be different for each instance).

Although the model is running well, when I select or open again the “Variable” activity, it changes itself the type to Global and then the model stops working with an error (exception: FlexScript exception: Property "name" accessed on invalid node. at MODEL:/Tools/ProcessFlow/SubFlow/Variable>variables/variableRef at line 6).

I was able to overcome this issue by using a “Custom Code” to access the tracked variable instead of the “Variable” activity, but I think it should be more convenient to do it by using the “Variable” activity (it make the process flow more readable). Is it a bug or dit I something wrong to make this work correctly ?

You can find attached a model that illustrated this issue.


TestVariable.fsm

FlexSim 24.1.0
tracked variablessub flowinstances
1715689103511.png (57.2 KiB)
testvariable.fsm (30.5 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @G. Moser, was Ralf Gruber's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

1 Answer

Ralf Gruber avatar image
0 Likes"
Ralf Gruber answered Jason Lightfoot commented

G. Moser,

The Tracked Variables you defined through the Tools are always global. If you need local Tracked Variables you have to define those on a node manually, e.g. in the tree of instance you are creating:

Tracked Variables (flexsim.com)

Good luck

· 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.

G. Moser avatar image G. Moser commented ·

Thanks for the answer, but what I find strange is that it works until I open the activity "Variable".

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ G. Moser commented ·
The timing of the evaluation of the variable reference in the subflow is unclear to me - I've suggested improving the documentation beyond say it's "evaluated at reset". As you've discovered the better way is to set the tv using custom code.
0 Likes 0 ·