Luke 18 Posted June 2, 2010 Report Share Posted June 2, 2010 After much time asking others here how to make more stable and trustworthy code, I've finally figured out the formula to make exactly that... And I'm no programmer, so I thought I'd put this chart together for other newbs/non-programmers here on exactly how to properly code parts of your bot so that every part of your bot fires off correctly and everything actually gets done. The secret is to split up every chunk of functionality into its' own sub first, and then code the following in each: If you don't use the optional node there, it will still keep looping until the job is done in the case of non-successful-completion. If you Do use that optional node before the work/Now sub, then you can check to see if data exists first before running that sub... So you don't accidentally reproduce any work. (As in the example of my cron job there, and in many other cases where you don't want to double your work.) It does take a little bit of creativity at times when you finish a chunk of code that results in no clear "success" message. But if you think hard about it there is always a way. I've just run a bot with 42 chunks of functionality in it (Chunk Example: Filling out a whole form and submitting it) with this around each chunk, and all fired off perfectly with no duplications and no skipped chunks! With this missing piece of knowledge mastered, I finally feel like uBot is starting to do what I bought it for... To create working custom apps. Hope this helps!Luke 3 Quote Link to post Share on other sites
alcr 135 Posted June 2, 2010 Report Share Posted June 2, 2010 I'm gonna merge this one with 'Streamline your headache - Create Error reports while you build!' if thats okay with you Luke? Might change the topic of them to something combined Great stuff anyways Quote Link to post Share on other sites
Luke 18 Posted June 2, 2010 Author Report Share Posted June 2, 2010 I'm gonna merge this one with 'Streamline your headache - Create Error reports while you build!' if thats okay with you Luke? Might change the topic of them to something combined Great stuff anyways No problem, I'm sure you know where it can help the most people. When you get around to filming tuts I think this is a subject that can use some deep exploration. Cheers,Luke Quote Link to post Share on other sites
alcr 135 Posted June 3, 2010 Report Share Posted June 3, 2010 Yeah, thats true. Quote Link to post Share on other sites
Luke 18 Posted June 19, 2010 Author Report Share Posted June 19, 2010 Just for the amusement of the hardcore programmers, and perhaps the education of other newbie programmers, I thought I'd let you guys know that I no longer make ANY SUBS AT ALL that don't have that While statement in them and set the success variable at the end, like in my picture above. Some scripts and subs will allow that optional first part, to check if the task has already been completed externally... Like when you want to see if a Widget you installed on a blog is showing up there or not, just as you go to set the widget up. But most subs don't need the external check first... They will ALWAYS, however, need the success variable and While statement though, if for no other reason than this: If anything ever goes wrong further down in the script past the first sub, then these success variables allow the subs that have been completed successfully to be skipped the next time you run the bot on that same project. Therefore, if you run a bot 9/10ths of the way through and something goes wrong, You can simply stop the bot, restart it, and it will pick up exactly at the start of the sub where it left off. I know the old-school jedi programmers here are snickering, but hey, it's been really exciting for me! I finally feel like I can create a reliable program now for the first time in my life. HTH, Luke 2 Quote Link to post Share on other sites
webautomationlab 21 Posted June 19, 2010 Report Share Posted June 19, 2010 Awesome tip Luke. I will make use of that since I use subs quite a bit. Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted June 27, 2010 Report Share Posted June 27, 2010 Hi Luke I got one question. what if the page has an error and the "while" command cant find specific code or text to move on.. Will it loop forever? Or can we set certain retries on "while" command? How to deal with this.. Thanks in advance. Quote Link to post Share on other sites
Luke 18 Posted June 27, 2010 Author Report Share Posted June 27, 2010 Hi Luke I got one question. what if the page has an error and the "while" command cant find specific code or text to move on.. Will it loop forever? Or can we set certain retries on "while" command? How to deal with this.. Thanks in advance. I doubt there is a way to limit retries, although that sounds like a great feature to ask Seth for. So far I've never needed it though; I mostly work with wordpress so things usually work or don't for me minus the occasional 1-time glitch... And those are what the while loop excels at working around. So it all comes down to testing most of the time... If the bot runs through all the situations you can throw at it without getting stuck in a never-ending loop then you're golden. I know that sounds grim but in practice it has not been as hard as it sounds to test. Cheers,Luke 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.