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

Iteration in script

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

Everyone's tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Iteration in script

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.

Anthony Holloway

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

Re: Iteration in script

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.

Anthony Holloway

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

Re: Iteration in script

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?

Re: Iteration in script

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.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
312
Views
3
Helpful
3
Replies
CreatePlease to create content