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

Increment Variable Name?

Hi, I am wondering how to increment a variable name suffix in a loop to check all variables in a series.  I have the following variables:

ANI1

ANI2

ANI3

...

ANI10

I want to compare the contact ANI to each of the ANI1 through ANI10 variables to look for a match.  So, would like the comparison to increment the number to check each of the 10 variables, like

if (iterator < 10) Then

    if (ANI==ANIBlock#)

         then do something

    increment iterator

How can I increment the # in the ANIBlock, to go through ANIBlock1, ANIBlock2, ANIBlock3, ... during the loop?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Super Bronze

Increment Variable Name?

Hi

Define a single variable, as an Array. You can then refer to it as ANIBlock(1), ANIBlock(2) etc to get at the individual vars, or iterate them with ANIBlock(variable) and a loop that increments 'variable' to identify each one.

Aaron

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

Increment Variable Name?

I suppose I could do a giant OR statement for the IF, but that could get ugly...

if (iterator < 10) Then

    if (ANI==ANIBlock1 || ANI==ANIBlock2 || ANI==ANIBlock3 || ANI==ANIBlock4 || ANI==ANIBlock5...)

         then do something

    increment iterator

Super Bronze

Increment Variable Name?

Hi

Define a single variable, as an Array. You can then refer to it as ANIBlock(1), ANIBlock(2) etc to get at the individual vars, or iterate them with ANIBlock(variable) and a loop that increments 'variable' to identify each one.

Aaron

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

Increment Variable Name?

Thanks Aaron.  That's a good way to go about it.

214
Views
0
Helpful
3
Replies
CreatePlease to create content