01-15-2010 11:28 AM - edited 03-14-2019 05:07 AM
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 ?
Solved! Go to Solution.
01-15-2010 11:37 AM
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)
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.
01-15-2010 11:37 AM
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)
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.
01-15-2010 11:40 AM
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.
01-15-2010 01:30 PM
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.
01-15-2010 01:37 PM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide