tooltrainer 12 Posted December 27, 2009 Report Share Posted December 27, 2009 I often have need for the classic If/Then/Else scenario, but there doesn't seem to be a way to do this in UBot. Am I missing something? For example, I need to see if a certain value is on the page, and if it is do one thing, if it's not do another. I suppose I could break things apart into subs and have the sub exit to another part of the script if a condition is met, but there should just be an "Else" option to give it the full standard suite of basic logic operations. Is this slated to be added? Or better yet is it already there and I'm just missing it? Jonathan Quote Link to post Share on other sites
crazyflx 22 Posted December 27, 2009 Report Share Posted December 27, 2009 I've actually had a need for the same thing, and I tried doing it the way you mentioned (breaking into subs and running one sub if the condition is met, and if it isn't allowing it to continue on the current one.) Then, I figured out a way to use the "not" function. Here is an example of how you would program it to do what you said in your example: Let's say I'm looking for the words "account successfully created" and if those words appear on the screen, then it goes to google.com and if those words DON'T appear on the screen then it goes to Yahoo.com. Here is how I'd program that: If > Search Page > "account successfully created"Then > Navigate > "www.google.com" If > Not > Search Page > "account successfully created"Then > Navigate > "www.yahoo.com" http://img6.imageshack.us/img6/108/notfunction.jpg Quote Link to post Share on other sites
tooltrainer 12 Posted December 27, 2009 Author Report Share Posted December 27, 2009 Ahhh... I had even been using the NOT function in other ways, and though this is slightly inefficient from a "real programmer" standpoint, it will definitely get the job done. Great workaround, thanks!!! Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted December 27, 2009 Author Report Share Posted December 27, 2009 Just dawned on me a possibly more efficient/faster solution... rather than have the node search the page all over again in order to test the NOT condition, just set a flag to true when the condition IS met, and test for it being true. Something like: Set #flag = FalseIf search page true, then set #flag = TrueIf #flag = False then do something else Saves on a search cycle and also allows for easy testing of that condition elsewhere in the script. Jonathan Quote Link to post Share on other sites
crazyflx 22 Posted December 27, 2009 Report Share Posted December 27, 2009 Ahhh, that is brilliant! Nice one man. Quote Link to post Share on other sites
tooltrainer 12 Posted December 28, 2009 Author Report Share Posted December 28, 2009 Yep, works nicely too, I've converted my script to use this approach and will use it a lot in the future. Wish there were user definable constants... though I suppose there's really no risk that a variable will spontaneously change during script execution. Jonathan Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.