question

Michael C18 avatar image
0 Likes"
Michael C18 asked Andrew O commented

SET LABEL Conditionally

screenshot-20-annotated.pngI am having trouble trying to set a label conditionally. I have tried several variations of an IF statement as the VALUE to no avail. Also, I have tried editing the code directly to no avail. In both case I get a compiler error. So clearly I do not understand the proper syntax. I have gone thru the documentation and the tutorial but cannot a specific case where the syntax is explained.

I am trying to set this Label during an "exit event" for a source.



FlexSim 22.2.1
setlabel
· 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.

Andrew O avatar image Andrew O commented ·

Hi @Michael C18, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Michael C18 commented

When editing the code directly, the proper syntax would be

if(current.JobIndex) {
    return 1;
}
return current.JobIndex+1;

"If the JobIndex is larger than 13, return 1, otherwise return JobIndex+1". The returned value is what will be assigned to the label.

In the pickoption field, you could use the following syntax "condition ? trueValue:falseValue"

1664475719316.png

Or, as a third option you could use the modulo operator "%".

1664475878216.png


1664475719316.png (9.3 KiB)
1664475878216.png (10.5 KiB)
· 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.

Michael C18 avatar image Michael C18 commented ·
Much thanks!


0 Likes 0 ·