Jump to content
UBot Underground

How to Error Check Each Sub Properly


Recommended Posts

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:

 

post-625-12755061117398_thumb.jpg

 

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

  • Like 3
Link to post
Share on other sites

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

Link to post
Share on other sites

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

Link to post
Share on other sites
  • 3 weeks later...

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

  • Like 2
Link to post
Share on other sites
  • 2 weeks later...

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.

Link to post
Share on other sites

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...