question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Jason Lightfoot commented

Fetching Global Variable Value Using String Variable?


Hi Team,

I am using string variable to get global variable value. But it is writing variable name instead of value. What is the right way to do it?


1654008091820.png

GlobalVariableUsingStringVariable.fsm

Thank you!

FlexSim 21.0.10
flexscriptstringglobal variable
5 |100000

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

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Jason Lightfoot commented

You can use the executestring() command to execute a text string as FlexScript code. For example:

  1. int val = executestring("Table" + "Value");
· 22
5 |100000

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

Kavika F avatar image
0 Likes"
Kavika F answered Ankur A3 commented

Hey @Ankur A3, from what I understand you want to retrieve the value of a cell from your global table using code? If so, then you're close! Right now, you're assigning the cell the value "TableValue". That's because whatever is on the left of the "=" will be assigned the value of whatever is on the right of the "=". If you want to retrieve the value rather than assign it, put it on the left like so: 1654021918505.png

I set a variable "var value" equal to the result of the right side (whatever is in the global table at that cell). Now you can use that value later on in the code if you want. Did this answer your question?


1654021918505.png (40.9 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.