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 / Returning empty string from function causes crash

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Jan 2011 20:01 Edited at: 10th Jan 2011 20:02
This only happens to me on Windows 7. For the long explanation, see here: http://forum.thegamecreators.com/?m=forum_view&t=180127&b=1&p=0

This snippet attempts to recreate the conditions related to the thread I posted above. The difference is that while this code will run, upon hitting a key it will crash when attempting to end the application. It's one of those generic errors, "DarkBASIC Pro Project has stopped working".



Now, making the simple change to return a string variable containing the empty string instead and the program will run and exit smoothly.




Additional note, it seems this happens if I return any string, not just an empty string. Storing the string into a variable first then returning it works fine.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Jan 2011 20:09
Ok, so I did a little searching after GreenGandolf mentioned this may have already been reported. I found the following issue confirmed which appears to be the same thing:
http://forum.thegamecreators.com/?m=forum_view&t=166555&b=15

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
sladeiw
14
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 10th Jan 2011 21:12
I guess this also affects using constants as return values?

eg:



Really annoying if so but could explain some weird bugs I've never fully explained. I use the above type of code A LOT! And the same goes for string constants, such as an invalid return string.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Jan 2011 13:47
Quote: "I guess this also affects using constants as return values?"


I'm not sure - I believe the error only applied to literal strings. In which case I'd expect problems if the constant was defined as a literal string - a string variable should be fine.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Jan 2011 17:14 Edited at: 11th Jan 2011 17:16
It's been around for quite a long time.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Jan 2011 19:14
I know returning values from functions has always been rather picking, like not being able to return a calculated value (endfunction a+b)

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
sladeiw
14
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 11th Jan 2011 21:15
Quote: "not being able to return a calculated value (endfunction a+b)"


That's another annoying thing with functions. I don't think DBPro's functions have advanced from even far back as BBC Basic! A great feature from back then was being able to update multiple variables local to another function/routine which could look something like this in db:



And also `mini` functions, great for improving readability:

Login to post a reply

Server time is: 2024-04-19 06:06:18
Your offset time is: 2024-04-19 06:06:18