cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
997
Views
3
Helpful
3
Replies

Iteration in script

Muhammad Usman
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

Anthony Holloway
Cisco Employee
Cisco Employee

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.

View solution in original post

3 Replies 3

Anthony Holloway
Cisco Employee
Cisco Employee

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.

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?

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.

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: