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 Professional Discussion / Problem returning string from function

Author
Message
Globbits
15
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 17th Aug 2010 11:53
I have encountered a strange problem this morning when running some very simple code on Windows 7 (32 bit). I'm sure this was working fine on XP yesterday, but it crashes on Win 7.



Both machines are running the latest DB Pro (7.5)

It's easy enough to fix, just by declaring and returning a string variable from the function instead of the "Yes" and "No" constants, however I can't see anything wrong with the code, and don't understand why it would work on one PC but not another.

Does anyone else get any problems with this?
luskos
16
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 17th Aug 2010 12:09
No problem with it here.I'm using XP.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Globbits
15
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 17th Aug 2010 12:23
Thanks Luskos. I couldn't remember have any problems with this on XP myself either. It may be a problem with DB Pro and Win 7.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 17th Aug 2010 12:44
This seems to be a Vista/7 bug that was never fixed. Awhile back someone posted a returning empty string bug, I think that it was never really about the empty string but just the fact that functions can't return string constants because of a bug that only appears in Vista/7.

You should post about this on the bug board so we can finally get this fixed.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Globbits
15
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 17th Aug 2010 13:29
Thanks Sasuke.
I have posted on the bug forum as you have suggested.

http://forum.thegamecreators.com/?m=forum_view&t=174328&b=15
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Aug 2010 14:18 Edited at: 17th Aug 2010 14:19
I don't know if this is relevant () but the syntax given in the Help file for endfunction is quite clear:

Quote: "Syntax

ENDFUNCTION Variable
"


and similarly for exitfunction.

If you don't follow the syntax and your program works that's just good luck. If it fails what do you expect?

I agree the compiler should recognize that you haven't followed the correct syntax though.

On the other hand the Help file for exitfunction also says:

Quote: "It is vital that if exit function command is used within a function declaration, that the return types are identical not only in data type, but whether they are arrays, variables or literals. You also cannot have expressions as part of the return data."


which suggests the stated syntax is wrong.

Anyone know what the correct syntax is for these two commands? IanM?
Globbits
15
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 17th Aug 2010 15:58
Thanks GG.
Yes, you're right. It's not for me to say whether this code should work or not, but I think it should be as black and white as that, not the sort of grey area it is at the moment.

I only became aware of a problem because I ran my compiled program on a Windows 7 PC and it crashed - not nice readable message either, but one of those generic "this program has stopped responding" errors. If I didn't have Win 7 to test it on, I would still be oblivious as it works fine on XP. This is really what I have an issue with. It took a while to find the culprit as well among 7000 lines of code.

We all want DB Pro to be as stable as possible right? Therefore it's in all of our interests to get this sort of thing sorted out.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Aug 2010 16:58
Quote: "not nice readable message either, but one of those generic "this program has stopped responding" errors"


Yes, those are really annoying.

Login to post a reply

Server time is: 2024-05-03 05:32:59
Your offset time is: 2024-05-03 05:32:59