question

j08j avatar image
0 Likes"
j08j asked j08j commented

Coding in flexscript

I have some questions about flexscript coding, how can I execute these steps using flexscript?

1. How to uncheck ”Fire OnResourceAvailable at Simulation Start" in the TaskExecuter panel?screenshot-2024-04-14-at-114838-am.png

2. How to add array label, edit the row number and the number in the array?screenshot-2024-04-14-at-114905-am.pngscreenshot-2024-04-14-at-114951-am.png

3. About the list properties, How can I delete those two expression field? I just want to leave "bound". Also, every time I re-execute the program, I hope to re-create TSList1 instead of continuously generating TSList2, TSList3,..., what can I do?screenshot-2024-04-14-at-114805-am.pngscreenshot-2024-04-14-at-121122-pm.png

Thank you very much in advance.

FlexSim 24.0.2
flexscriptcodingtasksequencesasrsvehicle
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

Arun Kr avatar image
1 Like"
Arun Kr answered j08j commented
  1. Object ASRSVeh = Model.find("ASRSvehicle1"); // AsRS Vehicle Ref
  2. ASRSVeh.setProperty("AvailableOnStart",0); // 1 for checking and 0 for unchecking the checkbox

The set property was found in the property table.

https://docs.flexsim.com/en/24.1/Reference/Tools/PropertyTables/PropertyTables.html#app

  1. ASRSVeh.LabelArray = [1,2,3];//LabelArray is the labelname

For array operations refer the Flexscript API's

FlexScript Class - Array (flexsim.com)

  1. treenode GlobalLists = Model.find("Tools/GlobalLists"); // Removing all tasksequence lists
  2. //Before creating new
  3. for(int i=1;i<=GlobalLists.subnodes.length;i++)
  4. {
  5. string ListType = GlobalLists.subnodes[i].find(">variables/listType").value;
  6. if(ListType == "TaskSequence")
  7. {
  8. GlobalLists.subnodes[i].destroy();
  9. }
  10. }
  11.  
  12.  
  13. treenode list = Tools.create("List","TaskSequence");// Tools API
  14. treenode focus = list;
  15. string fieldTypeName = "ExpressionField";
  16. treenode newField = function_s(focus, "addField", fieldTypeName);
  17. newField.name = "bound";
  18. treenode Expression = newField.find("expression");
  19. string Code = "/**Custom Code*/ Variant value = param(1);\
  20. Variant puller = param(2);\
  21. treenode entry = param(3);\
  22. double pushTime = param(4);\
  23. return 5;";
  24. Expression.value = Code;
  25. list.find(">variables/fields/age").destroy(); // Removing first two fields
  26. list.find(">variables/fields/distance").destroy();
· 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.