question

Enrique Elizaga avatar image
0 Likes"
Enrique Elizaga asked Matthew Gillespie edited

How do you execute flexscript in a label?

I created a label with data type Flexscript. How do you execute it in the code of the object?

FlexSim 18.2.3
labels
5 |100000

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

Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered Matthew Gillespie edited

Just get the value through dot syntax like you normally would:

double delay = current.ProcessingTime;

This will execute the flexscript on the ProcessingTime label if it is flexscript type and return the value.

If you want to pass in parameters you need to get the label node and call evaluate on it.

double delay = current.labels["ProcessingTime"].evaluate(5);
5 |100000

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

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

The method is evaluate

current.labels["MyFlexScriptLabel"].evaluate();

or

nodefunction(node("MyFlexScriptLabel",labels(current));

I was not able to pass parameters into the function similar to the description of the manual.

execute-label-flexscript.fsm


· 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.

Phil BoBo avatar image Phil BoBo ♦♦ commented ·

You specified param(0) to try to get the parameter. Parameters start at 1. Use param(1):

0 Likes 0 ·
param1.png (22.0 KiB)
Joerg Vogel avatar image Joerg Vogel Phil BoBo ♦♦ commented ·

Thanks Phil. I set the parameter to 1 today in the morning. I didn't get any results, now after loading the model again everything is fine.

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.