cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1392
Views
0
Helpful
4
Replies

UCCX Scripting

cris_jimenez
Level 2
Level 2

I have a question, i'm in the middle of programming a scripting and just realized that i need to create a nested if step.

Do you know what's the maximum if's that can be nested? I need to nest 25 ifs on my script

or if you could recommend a better way to do it I'd appreciated it

this is what i need to do pretty much on this step

based on the CalledNumber I need to set a fixed password to a variable. do you know a way to do this besides the nested ifs ?

1 Accepted Solution

Accepted Solutions

Tanner Ezell
Level 4
Level 4

Cris,

Try this:

String[] stringContainer

int counter

/* I'm going to assume you know how to read from an XML Document, if not I can help you */

/* create a loop to run through getting lines from the XML file */

Loop Start:

xmlString = Get XML Document Data ("/descendant::Passwords/child::Password" + counter)

if(xmlString != null)

     True:

         stringContainer = xmlString.split(";")

          if (stringContainer[0] == )

               True:

                    /* set your password, password will be in stringContainer[1] */

                    /* do whatever then break the loop */

               False:

                    Increment Counter

                    Goto Loop Start

In your XML document, format it as such (names are irrelevant)

     5000;cisco

     5001;c1sco

The format is simple: CalledNumber;Password

The script will run through the file testing stringContainer[0] (the called number) against whatever variable you have stored the called number in. If it finds it, the password will be in stringContainer[1]

Let me know of any questions.

Tanner Ezell www.ctilogic.com

View solution in original post

4 Replies 4

Tanner Ezell
Level 4
Level 4

Cris,

Try this:

String[] stringContainer

int counter

/* I'm going to assume you know how to read from an XML Document, if not I can help you */

/* create a loop to run through getting lines from the XML file */

Loop Start:

xmlString = Get XML Document Data ("/descendant::Passwords/child::Password" + counter)

if(xmlString != null)

     True:

         stringContainer = xmlString.split(";")

          if (stringContainer[0] == )

               True:

                    /* set your password, password will be in stringContainer[1] */

                    /* do whatever then break the loop */

               False:

                    Increment Counter

                    Goto Loop Start

In your XML document, format it as such (names are irrelevant)

     5000;cisco

     5001;c1sco

The format is simple: CalledNumber;Password

The script will run through the file testing stringContainer[0] (the called number) against whatever variable you have stored the called number in. If it finds it, the password will be in stringContainer[1]

Let me know of any questions.

Tanner Ezell www.ctilogic.com

Tanner Ezell
Level 4
Level 4

To answer your original question,

No, there is no limit to how many nested ifs (or anything for that matter) there are. The only limit is based on how many Steps will be executed per step.

Tanner Ezell www.ctilogic.com

I have nothing against using an XML source document (although that is a unique way of formatting the data in XML); however, you can also just use a Switch step. This would collapse all of your If steps into a single level.

Using the XML file has the advantage of allowing you to modify it without having to reload the application and script.

You could probably argue that from a maintenance stand point that the XML file is easier to manage (for those who are perhaps not comfortable with scripting, for instance).

Of course there is the downfall that if someone goes mucking around and deletes the XML file, you're screwed

Tanner Ezell www.ctilogic.com
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: