Jump to content
UBot Underground

How to avoid a stack overload?


Recommended Posts

I am quite new to programming, but have put together a bot in the following structure:

 

Within script:

 

Create table from file

setup UI monitors

Set variables based on table

Run 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

Link to post
Share on other sites

I am quite new to programming, but have put together a bot in the following structure:

 

Within script:

 

Create table from file

setup UI monitors

Set variables based on table

Run 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

Link to post
Share on other sites

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.

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...