question

Lucas Braga avatar image
2 Likes"
Lucas Braga asked Brandon Peterson commented

Using Global Variables on a Global Table

So, I created a Global Variable that I want to assign to a cell on a Global Table, but the only options that show up are: Assign Number Data and String Data. Can you help me? ~The variable is an integer.

FlexSim 7.5.4
global variablesvariable
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

·
Steven Hamoen avatar image
4 Likes"
Steven Hamoen answered Brandon Peterson commented

If you Global Variable is an integer it is a number so you can simply use;

settablenum( "tablename", rowno, colno, GlobalVariableName )

· 4
5 |100000

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

Lucas Braga avatar image Lucas Braga commented ·

On the table cell? I'm trying, but nothing happens.

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen commented ·

I attached a screenshot.

0 Likes 0 ·
Mischa Spelt avatar image Mischa Spelt Steven Hamoen commented ·

I assume by "assigning a global variable to a table cell" you mean that you want the value in the table cell to automatically change when you change the global variable? Because that is not possible. What you can do is use the settablenum command as demonstrated by Steven, but you would have to do it on reset and every time you change the variable.

Alternatively, you could make the table column string data, and read it out with executetablecell (or use the 'Automatic' option in Process Flow).

1 Like 1 ·
Brandon Peterson avatar image Brandon Peterson ♦ Mischa Spelt commented ·

An alternative method would be to make the global variable a tree node type that points to the cell in the global table. You can then use getnodenum(GlobalVariableName) and setnodenum(GlobalVariableName, Value) to get and set the value. This method is not as smooth when getting or using the global variable in a function but it does eliminate the need for a second command call to set the value of the table each time you change the global variable.

4 Likes 4 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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