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
Object ASRSVeh = Model.find("ASRSvehicle1"); // AsRS Vehicle Ref
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

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

For array operations refer the Flexscript API's

FlexScript Class - Array (flexsim.com)

treenode GlobalLists = Model.find("Tools/GlobalLists"); // Removing all tasksequence lists 
//Before creating new
for(int i=1;i<=GlobalLists.subnodes.length;i++)
{
   string ListType = GlobalLists.subnodes[i].find(">variables/listType").value;
   if(ListType == "TaskSequence")
    {
      GlobalLists.subnodes[i].destroy();
    }
}


treenode list = Tools.create("List","TaskSequence");// Tools API
treenode focus = list;
string fieldTypeName = "ExpressionField";
treenode newField = function_s(focus, "addField", fieldTypeName);
newField.name = "bound";
treenode Expression = newField.find("expression");
string Code = "/**Custom Code*/ Variant value = param(1);\
   Variant puller = param(2);\
   treenode entry = param(3);\
  double pushTime = param(4);\
   return 5;";
   Expression.value = Code;
 list.find(">variables/fields/age").destroy(); // Removing first two fields
 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.

Felix Möhlmann avatar image Felix Möhlmann commented ·
Rather than removing the tow default fields, you can also just create a general list instead. The only difference between the list types is what fields they possess by default and which fields are available to add via dropdown menu.
1 Like 1 ·
j08j avatar image j08j commented ·

Thanks for the clarification!

0 Likes 0 ·

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.