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?
GlobalVariableUsingStringVariable.fsm
Thank you!
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?
GlobalVariableUsingStringVariable.fsm
Thank you!
You can use the executestring() command to execute a text string as FlexScript code. For example:
int val = executestring("Table" + "Value");
This solution is working fine if I want to write global variable value.
I also want to change global variable value in similar fashion. It is not working in the same way. What is the right way to do it?
Thank you!
executestr(str1+"Value")
returns number. So you're then setting a number (eg. 5) to 80 - which doesn't make sense. You seem to want
executestring(str1+"Value=80");
But this looks all very poorly structured to me - it might serve you better to thing about the wealth of supported data structures and data types in FlexSim and choose something different (Maps, Arrays, Tables, Lists, Pointers).
Hi @Jason Lightfoot,
Thanks for your answer!
Actually, I have series of global variables having some common text (Eg: Obj1_Mon_Utilization, Obj2_Tue_Utilization etc). I have to access all variables for n number of objects. So, I want to create a object loop for better scalability.
Would you like to suggest any other approach?
Thank you!
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:
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?
17 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved