question

10Dulkar avatar image
0 Likes"
10Dulkar asked Joerg Vogel edited

Code

i was going through one model on Time table and i saw a code there, which i dont know how to read in FlexScript. can someone elaborate what does the following code does and and what is the meaning of keywords and symbols used in it.

return /**/token.Shift == 1 ? token.Day + 1 : token.Day/**direct*/;


what is the meaning of "?" and ":" in the above code.


FlexSim 21.2.2
flexsim 21.2.2costum codeternary operator
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

Phil BoBo avatar image
2 Likes"
Phil BoBo answered 10Dulkar commented

It is a ternary operator. See Writing Logic in FlexSim and ?: - Wikipedia

It is a shortcut way to write an if/else statement in one line.

In that code, if token.Shift == 1, then it will return token.Day + 1, otherwise it will return token.Day.

/**/ and /**direct*/ are commentary markup statements used by the popup GUI.

· 1
5 |100000

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

10Dulkar avatar image 10Dulkar commented ·
this is great. thank you. I will check out the writing flexsim logic with more attention. :)
0 Likes 0 ·