×

Warning message

  • Cisco Support Forums is in Read Only mode while the site is being migrated.
  • Cisco Support Forums is in Read Only mode while the site is being migrated.

Iteration in script

Answered Question
Aug 9th, 2013
User Badges:

Does UCCX 8.5 supports while or for loop, if it does then some one can please share syntax of it. Thanks

Correct Answer by Anthony Holloway about 4 years 1 week ago

Yes is does.  In fact, you can type any Java code you want into the editor, you just have to know how to include it.  So for example, if you wanted to loop 10 times, adding each number to the next, and store the output in an int variable:


Do {

  int i;

  for (i = 1; i <= 10; i++) {

    my_num = my_num + i;

  }

}


This assumes you have a variable called my_num.  You can use Java blocks anywhere in your script where the expression editor exists.


Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 4 (2 ratings)
Loading.
Correct Answer
Anthony Holloway Fri, 08/09/2013 - 18:13
User Badges:
  • Purple, 4500 points or more

Yes is does.  In fact, you can type any Java code you want into the editor, you just have to know how to include it.  So for example, if you wanted to loop 10 times, adding each number to the next, and store the output in an int variable:


Do {

  int i;

  for (i = 1; i <= 10; i++) {

    my_num = my_num + i;

  }

}


This assumes you have a variable called my_num.  You can use Java blocks anywhere in your script where the expression editor exists.


Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Muhammad Usman Sat, 08/10/2013 - 11:42
User Badges:

Thanks Anthony.. it worked..

Out of curiosity, in Java we can define variable in for loop, like

for(int i=0; i<10; i++)

but here, it was not allowing me, i had to first create int variable and then call that variable in for loop, like you mentioned above, why is it not allowing me to create variable inside for loop?

Anthony Holloway Sun, 08/11/2013 - 21:40
User Badges:
  • Purple, 4500 points or more

I don't know, but that's exactly why I wrote it that way.  There's some differences between pure Java and UCCX.


Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Actions

This Discussion

Related Content