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.

Bug Reports / RETURN statement in functions

Author
Message
knight42
18
Years of Service
User Offline
Joined: 14th Oct 2005
Location:
Posted: 15th Oct 2005 23:29
My first post!

Including a RETURN statement inside a function causes the program to exit immediately without running. I've attached code that demonstrates - if either RETURN statement in the function is commented out, the program works correctly, if either RETURN is included it will not run. It also crashed DBPCompiler after a few tries at running it in the debugger.

I'm using DBPro Online updated with the 5.8 updater on Windows XP SP2.
re faze
19
Years of Service
User Offline
Joined: 24th Sep 2004
Location: The shores of hell.
Posted: 16th Oct 2005 00:15
uh... you use exitfunction or endfunction to leave a function NOT return if you use return you probably mess up the pointers to the different areas in the program hence the crash. NEVER use RETURN in a function!(or at all...)

you dont beat the system. the system beats you.
knight42
18
Years of Service
User Offline
Joined: 14th Oct 2005
Location:
Posted: 16th Oct 2005 00:59
So you can't use GOSUB within a function, then? I'm not looking to get out of the function, but return to where I was.

As it happens I don't need it as I've found there is an ENDIF statement after all, which isn't documented along with IF...!
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Oct 2005 02:01
Quote: "So you can't use GOSUB within a function, then? I'm not looking to get out of the function, but return to where I was."


You can have gosub in a function as long as it gosubs to somewhere inside the function it's already in... but it's best to avoid it if you can... and you did... great!

And any code you want to post is best done with the code snips (take out the spaces between the brakets).

[ code ]
Your code.
[ /code ]
re faze
19
Years of Service
User Offline
Joined: 24th Sep 2004
Location: The shores of hell.
Posted: 16th Oct 2005 02:58
yeah your begging for a memory problem if you use gosub/goto within a function

you dont beat the system. the system beats you.
knight42
18
Years of Service
User Offline
Joined: 14th Oct 2005
Location:
Posted: 16th Oct 2005 14:11
My apologies, gentlemen, I didn't realise the code hadn't been posted. Here it is:



I have a GOSUB...RETURN entirely within the function, but if either RETURN statement is uncommented, then the program simply exits as soon as it starts.

It doesn't matter now, as I was just trying to avoid a huge line of code after an IF...THEN which I've now solved with an ENDIF. I was just wondering why including a RETURN in a function causes a crash.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Oct 2005 14:46
The bug is all yours - this is how the code should have been written:



For free Plug-ins and source code http://www.matrix1.demon.co.uk
re faze
19
Years of Service
User Offline
Joined: 24th Sep 2004
Location: The shores of hell.
Posted: 16th Oct 2005 18:35
in a function?!

you dont beat the system. the system beats you.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Oct 2005 23:47
DBPro allows gosub/return within the same scope, ie. at function or main-code level.

I'm not sure how it deals with a gosub out of a function, but I don't really care because I never use gosub/return. The only time I use labels is for labelling DATA so that I can RESTORE to that point.

For free Plug-ins and source code http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2024-04-19 20:06:00
Your offset time is: 2024-04-19 20:06:00