question

Alfredo DF2 avatar image
0 Likes"
Alfredo DF2 asked Matthew Gillespie commented

Global variable and Global table by script

Hi,

is it possible to insert global variable (both int/doble both array) and global table directly by script?

Thank you all!

FlexSim 17.2.5
global tablescriptglobal variablesdebug
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

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Matthew Gillespie commented

The last part of your question has answered @steven.hamoen already at "create a Global Table in flexscript". Maybe you adjust my answer at the same question there to add global variables by source code.

EDIT: Try for Global Variables

  1. treenode globalVariableNode = model().find("Tools/GlobalVariables");
  2. treenode newVariable = createcopy(globalVariableNode.first,globalVariableNode,0);
  3. newVariable.name = "myNewVariable";
  4. newVariable.subnodes[1].value = "myNewVariable";
  5. newVariable.subnodes[2].value = 4; // Type 1: int/ 2: double/ 3: treenode/ 4: string /5: Array
  6. newVariable.subnodes[3].dataType = DATATYPE_STRING;
  7. newVariable.subnodes[3].value = "MyData";// Array entries as Subnodes, Datatype is string
  8. refreshglobalvariables();
  9. buildnodeflexscript(model());
  1. treenode globalVariableNode = model().find("Tools/GlobalVariables");
  2. treenode newVariable = createcopy(globalVariableNode.first,globalVariableNode,0);
  3. newVariable.name = "myNewVariable";
  4. newVariable.subnodes[1].value = "myNewVariable";
  5. newVariable.subnodes[2].value = 5; // Type 1: int/ 2: double/ 3: treenode/ 4: string /5: Array
  6. newVariable.subnodes[3].dataType = DATATYPE_STRING;
  7. newVariable.subnodes[3].value = "1";// Array entries as Subnodes, Datatype is string
  8. newVariable.subnodes[3].subnodes.assert("1","3"); // the node name is typically blank
  9. // then you can only add one entry
  10. newVariable.subnodes[3].subnodes.assert("2","newvalue");
  11. newVariable.subnodes[3].subnodes.assert("3","ddd");
  12. refreshglobalvariables();
  13. buildnodeflexscript(model());
  14.  
· 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.