question

Ankith T avatar image
0 Likes"
Ankith T asked Jason Lightfoot edited

how to create a function and be able to call it for returning a value.

Hi, i would like to create a function using flexscript, where when i call the function, it has to return the some value according to the calculation i put inside the function.


Example

1690314752039.png


here i am just trying to create a addition function where if i send two values, it has to save that number at specified table and return me the added value "C" for the variable "dd".

FlexSim 21.1.5
customcodefunctionsflexscript coding
1690314752039.png (5.0 KiB)
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

Julie Weller avatar image
0 Likes"
Julie Weller answered Jason Lightfoot edited

Hi @Ankith T! You can add a function by going to Toolbox -> Modeling Logic -> User Commands. This will allow you to make a little function for your model. You can add the code at the bottom. Here's a link to the documentation for the tool: https://docs.flexsim.com/en/23.1/Reference/Tools/UserCommands/UserCommands.html#app

Let me know if you have any follow up questions!

· 9
5 |100000

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

Ankith T avatar image Ankith T commented ·
if i would like to send couple of values, how to i mention that in code section?
0 Likes 0 ·
Julie Weller avatar image Julie Weller Ankith T commented ·

Here's an example for what you want to do:

1690316904328.png

1690316917791.png

0 Likes 0 ·
1690316904328.png (39.0 KiB)
1690316917791.png (23.5 KiB)
Ankith T avatar image Ankith T Julie Weller commented ·
Thank you, that cleared my doubt. But what if i would like to return multiple variables. such as string and double. where string tells me its an addition and double tells me the value of addition.
0 Likes 0 ·
Show more comments