cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1174
Views
5
Helpful
4
Replies

IF Statement / Switch Statement / IF, Else, Then

B_VOIP_NE
Level 1
Level 1

Hello,

 

I am working on a script that captures expected wait times.  It seems like the best way to handle this is to capture this data into an integer via get reporting statistic > expected wait time.  The problem I am having is what to do with this value after.  I know I can do an if then statement however, what seems like an even better option is the switch statement.  I can't figure out how to use an evaluation within the switch statement.  Would someone please let me know the best way to do this?

 

For example, I wanted to do something like this

 

 

if (expected wait time is < 0) play prompt 1
if (expected wait time is > 0 and < 60) play prompt 2
if (expected wait time is > 60 and < 300) play prompt 3
if (expected wait time is > 300) play prompt 4

 

Currently I only see a way to evaluate one option using the If step and when looking at the switch step I don't see a way to evaluate based on greater than or less than.  It appears the switch step will only allow me to match a condition exactly.

1 Accepted Solution

Accepted Solutions

Sean Lynch
Level 7
Level 7

I don't think there is anything wrong with using nested IF statements.  There are fewer evaluation steps here than you think.  Only three, not four.

scPlayPromptEWT.PNG

There isn't anything wrong with adding logic and another step item--Switch step.  It only counts against your total step count. 

 

If all you are doing is playing a single prompt, save yourself a few steps.  ...just make sure you account for the "or equals" values as well (in your post above you have potential gaps... equals 0 and at equals 60--which could be a potential result).

 

Sincerely,

Sean

View solution in original post

4 Replies 4

If I remember correct the switch step needs specific values like:

1->Connection1

30->Connection30

etc.

 

So after you get the EWT, do a calculation figuring out what case is the right case, set the new EWT and then pass that to your switch step.

 

david

Sean Lynch
Level 7
Level 7

I don't think there is anything wrong with using nested IF statements.  There are fewer evaluation steps here than you think.  Only three, not four.

scPlayPromptEWT.PNG

There isn't anything wrong with adding logic and another step item--Switch step.  It only counts against your total step count. 

 

If all you are doing is playing a single prompt, save yourself a few steps.  ...just make sure you account for the "or equals" values as well (in your post above you have potential gaps... equals 0 and at equals 60--which could be a potential result).

 

Sincerely,

Sean

Thanks!

Anthony Holloway
Cisco Employee
Cisco Employee

The switch step will not do what you want, and you will need to use several if steps. 

 

"An if-then-else statement can test expressions based on ranges of values or conditions, whereas a switch statement tests expressions based only on a single integer, enumerated value, or String object."


Source: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html

 

Alternatively, you could use a Do step, and write your own if then else block. 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: