Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

Best way to do Integer math in a script? - CUCCX 7.x

Anyone have anything better than this?

set int_1 = 1

set int_2 = 2

set int_3 = 3

set int_4 = 4

set int_5 = 5

set int_total = (int_1 + int_2 + int_3 + int_4 + int_5)

if (int_total >= int_maxvalue)

true

goto Label_1

false

goto Label_2

1 ACCEPTED SOLUTION

Accepted Solutions
Super Bronze

Re: Best way to do Integer math in a script? - CUCCX 7.x

Hi

You can't do that, I'm afraid... and in your scenario there's not much value being added.

You could, for example, put the return variables into an Array of integers; however there's no specific 'sum of this array' method as an Array could hold ints, Strings, apples, or pears in Java.

If you did that you would then need a looping structure to go through the Array and add each value to another int; that would only be worthwhile if the number of elements in the array varied between executions of the script. Since you have static variables in this script, it all would just make it much more complicated and difficult to follow.

So to put it simply - what you have is simple to read, quick to execute, and works... so it's as good as it can be.

Regards

Aaron

Please rate helpful posts...

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!
6 REPLIES
Super Bronze

Re: Best way to do Integer math in a script? - CUCCX 7.x

You can emded a bunch of java code into the SET or DO steps, which might reduce the number of steps you need if that's what you are trying to do.

So you may be able to embed the code from the first five steps into the addition step...

Do you have a more concrete example?

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!
New Member

Re: Best way to do Integer math in a script? - CUCCX 7.x

What I'm doing as adding the number of contacts waiting for 5 different CSQ's..

If the total is greater than the threshold set by the helpdesk manager, ship the caller directly to voicemail.

icounter_1 = Get Reporting Statistic (Contacts Waiting[sQueueName_1] from CSQ IPCC Express)

icounter_2 = Get Reporting Statistic (Contacts Waiting[sQueueName_2] from CSQ IPCC Express)

icounter_3 = Get Reporting Statistic (Contacts Waiting[sQueueName_3] from CSQ IPCC Express)

icounter_4 = Get Reporting Statistic (Contacts Waiting[sQueueName_4] from CSQ IPCC Express)

icounter_5 = Get Reporting Statistic (Contacts Waiting[sQueueName_5] from CSQ IPCC Express)

iTotal_Calls = (icounter_1 + icounter_2 + icounter_3 + icounter_4 + icounter_5)

If (iTotal_Calls > = iOverflow_Threshold)

True

     Goto VOICEMAIL REDIRECT

False

     Goto MAIN MENU

Super Bronze

Re: Best way to do Integer math in a script? - CUCCX 7.x

I see.

Well.. you need your seperate get reporting steps.


And you have one step that adds 'em up..

It's difficult to see how that could be optimised... which bit do you not like?

You could dump the math into the IF statement, which would save a step but lose readability...

Aaron

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!
New Member

Re: Best way to do Integer math in a script? - CUCCX 7.x

I was hoping for something like

int iTotal_Calls = new integer sum(icounter_[1,5])

But I couldn't find any "sum" operation for a wildcarded list of integers.

Wishful thinking on my part I suppose.

Super Bronze

Re: Best way to do Integer math in a script? - CUCCX 7.x

Hi

You can't do that, I'm afraid... and in your scenario there's not much value being added.

You could, for example, put the return variables into an Array of integers; however there's no specific 'sum of this array' method as an Array could hold ints, Strings, apples, or pears in Java.

If you did that you would then need a looping structure to go through the Array and add each value to another int; that would only be worthwhile if the number of elements in the array varied between executions of the script. Since you have static variables in this script, it all would just make it much more complicated and difficult to follow.

So to put it simply - what you have is simple to read, quick to execute, and works... so it's as good as it can be.

Regards

Aaron

Please rate helpful posts...

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!

Re: Best way to do Integer math in a script? - CUCCX 7.x

I'm so glad he later posted the real reason behind the question, because this:

set int_1 = 1

set int_2 = 2

set int_3 = 3

set int_4 = 4

set int_5 = 5

set int_total = (int_1 + int_2 + int_3 + int_4 + int_5)

...is plain crazy.  Why not just post the real question to begin with?  You know?

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
272
Views
0
Helpful
6
Replies
CreatePlease to create content