4DScript If statement with 4 options

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Hanna
Posts: 3
Joined: Wednesday 03 April, 2019 - 12:05

4DScript If statement with 4 options

Post by Hanna » Wednesday 03 April, 2019 - 13:11

Hi everyone,

I am looking for a way to insert 4 statements in a if statement.

I understand how to do it with 2 options:

Code: Select all

If(Label([Type],i)=1,
hr(1),
hr(2))
But I have four product types with all different processing time on the same workstation (server).
I made four arrival lists with a trigger on exit: Label([Type], i) := 1

Can someone help me please?

User avatar
HarryBunnik
Posts: 304
Joined: Monday 07 February, 2011 - 11:22

Re: 4DScript If statement with 4 options

Post by HarryBunnik » Wednesday 03 April, 2019 - 13:18

Ha Hanna,

You could try a case statement in combination with a WhichIsTrue for this (I used random values for the Label([Type],i)):

Case(
WhichIsTrue(
Label([Type], i) = 1,
Label([Type], i) = 3,
Label([Type], i) = 9,
Label([Type], i) = 12
),
hr(1), {Option 1}
hr(2), {Option 2}
hr(3), {Option 3}
hr(4) {Option 4}
)

I hope this helps you further!

Greetings, Harry

Hanna
Posts: 3
Joined: Wednesday 03 April, 2019 - 12:05

Re: 4DScript If statement with 4 options

Post by Hanna » Wednesday 03 April, 2019 - 13:39

Thankyou Harry!
This works!

Post Reply