steveh 0 Posted January 21, 2011 Report Share Posted January 21, 2011 I am quite new to programming, but have put together a bot in the following structure: Within script: Create table from filesetup UI monitorsSet variables based on tableRun sub(mainbody), so within mainsub:run sub(check) - will check if a counting variable has exceeded a number of repeats, if so stop.run sub(task1)run sub(task2)run sub(mainbody repeater)* This just runs the mainsub again (if I say to run mainbody immediately without this step it crashes). I read elsewhere that using lots of subs, especially within subs can cause a stack overload. How else would I structure it? Steve Quote Link to post Share on other sites
Net66 54 Posted January 21, 2011 Report Share Posted January 21, 2011 I am quite new to programming, but have put together a bot in the following structure: Within script: Create table from filesetup UI monitorsSet variables based on tableRun sub(mainbody), so within mainsub:run sub(check) - will check if a counting variable has exceeded a number of repeats, if so stop.run sub(task1)run sub(task2)run sub(mainbody repeater)* This just runs the mainsub again (if I say to run mainbody immediately without this step it crashes). I read elsewhere that using lots of subs, especially within subs can cause a stack overload. How else would I structure it? Steve Calling a sub within a sub doesn't cause a problem for ubot but if that sub in turn calls another sub and that calls another... you're going to have to issues in all likelyhood. Just avoid nesting too deep and the stack will be fine. Andy Quote Link to post Share on other sites
steveh 0 Posted January 21, 2011 Author Report Share Posted January 21, 2011 Hi It usually crashes after a few iterations (not many, about 5 or so) on the run mainbody sub Quote Link to post Share on other sites
UBotBuddy 331 Posted January 21, 2011 Report Share Posted January 21, 2011 Ditto to what Andy said. Watch the flow of your Subs. I have quite a few Sub in my bots but I do not call a Sub from within a Sub unless I absolutely have to. Also, Nesting can be a nasty thing if you do not set it up right. Quote Link to post Share on other sites
steveh 0 Posted January 21, 2011 Author Report Share Posted January 21, 2011 ok thanks. 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.