Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Multiple Gosubs cause Memory issues?

Author
Message
BLink
21
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 26th May 2006 01:35
Is my PC just acting weird or something? I'm using a menu system with a couple of different gosubs and return commands, but they don't overlap(to my knowledge). I have the code set up as...

do
if var#=1 then gosub section1
if var#=2 then gosub section2
loop

section1:
delete old images if existant
load sec1 images
do
if mouseclick()=1 then var#=2:return
sync
loop

section2:
delete old images
load sec2 images
do
if mouseclick()=1 then var#=1:return
sync
loop


Is there anything wrong with laying out my code like that? I've found that if I remove the "var#=1:return" parts of section2, the code will work( say if I have the mouseclick scale an image instead), but I really don't know what's going on. It used to say that I was having memory problems, but now it just closes Dark Basic on me.

I will try restarting my computer, but that takes a while, and I've been having trouble with my menu system a ton so far, so I thought it would be worth my time to check in here anyways. And yes, that's a very simplified version of what I've got for my code.

Pineapple juice, the best drink ever made.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 26th May 2006 07:28
What's the error your getting ?

If it's a stack overflow, then one (or more) of your gosubs is missing a RETURN.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th May 2006 10:08
Well there are different ways to code what you are doing. I don't suppose DB likes the Return in a loop like that. So just code it a different way.

BLink
21
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 27th May 2006 20:19
The thing is, I'm not really sure what other ways I ought to try. Do you guys have any suggestions?

Pineapple juice, the best drink ever made.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th May 2006 20:23
Depends on what code you have in the loop, but this works with the loop that you posted....

section1:
Repeat
Until Mouseclick() = 1
var#=2
Return

BLink
21
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 13th Jun 2006 21:48
forgot to get back on this to you guys.

I ended up looking on some other code and realizing that it was too many return commands to remember, but that goto commands would work with a destination that came higher up in the command than the action itself, so I basically just switched all the gosubs with gotos and the returns with gotos. Everything worked out fine.

Pineapple juice, the best drink ever made.

Login to post a reply

Server time is: 2025-05-25 01:59:51
Your offset time is: 2025-05-25 01:59:51