12-11-2015 05:39 AM - edited 03-14-2019 03:33 PM
Hi,
I have UCCX 10.6 and I have a question about scripting.
When I have an integer like 5 10 or 15 I can use a switch statement to make a decision. But what if I have to make a decision if a value is between 5 and 10 or between 10 and 15?
This can be solved with nested if statements, but I was wondering if there is someone who came up with a better (easier) way of check a value.
Thanks
JH
12-11-2015 06:00 AM
I am not aware of cleaner method, "if X<10 && X>5 where && stands for AND would cover one scenario.
12-11-2015 06:07 AM
Hello Chris,
Yes I am using && and I ended up with 10 nested IF statements. It does do the job, but it's a little ugly.
Thanks for your input
Jan
12-11-2015 06:36 AM
Unless someone can propose some Java code you could use there is no native way with pre-defined steps to accomplish this AFAIK.
12-16-2015 01:50 AM
I could give you some Java code you could slip into a do or set step, but that would be equally ugly :-)
Also based on the outcome of the IFs, you want to do something (I presume)... the IF statements give you somewhere to put those steps.
In terms of layout, I prefer:
IF (x > 0 && < 5)
- True: do this
- False: do that
IF (x > 5 && < 15)
- True: do this
- False: do that
IF (x > 15 && < 25)
- True: do this
- False: do that
... etc
Rather than:
IF (x > 0 && < 5)
- True: do this
- False: do that
-- IF (x > 5 && < 15)
--- True: do this
--- False: do that
---- IF (x > 15 && < 25)
----- True: do this
----- False: do that
..etc
.. i.e. count on the fact that once an if branch has been followed, the next step down will execute - you don't have to nest them in, I think having them laid out sequentially aids readability.
Aaron
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide