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 / Endfunction - Exitfunction bug

Author
Message
DSG
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Hampshire, England
Posted: 3rd Feb 2006 02:28 Edited at: 3rd Feb 2006 02:32
The following code produces the error:

Quote: "ENDFUNCTION and EXITFUNCTION must return the same data type at line ..."


However, both IntArray(0) and n are clearly (and explicitly defined as) integers.



Danny Gregory
BSc Computer Science - UG
University of Southampton
Mattman
20
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 3rd Feb 2006 04:23
I find returning arrays not a fun thing in DBP.

Why make sense when you could make brownies?
Torrey
19
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 3rd Feb 2006 06:05 Edited at: 3rd Feb 2006 06:06
DBPro most likely interprets arrays like "IntArray(0)" as DWORD pointers and not integer values. Functions in dbpro need to end a function with the same variable type. In your case you'd need to do something like:



And for testing purposes I tossed in these commands and ran it through the dbpro debugger.



Executed perfectly.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Feb 2006 13:09
When this 'difficulty' appeared during an upgrade and broke some code I had, I just added 0 to the number and that solved the problem.

For free Plug-ins and source code http://www.matrix1.demon.co.uk
DSG
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Hampshire, England
Posted: 3rd Feb 2006 14:57
Quote: "DBPro most likely interprets arrays like "IntArray(0)" as DWORD pointers and not integer values"


In many languages, it is standard that an array identifier that is followed by a subscript suffix will resolve to the array element that the subscript index maps to. If DBPro breaks this convention, then it isn't documented anywhere in its help files.


Quote: "When this 'difficulty' appeared during an upgrade and broke some code I had, I just added 0 to the number and that solved the problem."


Sure, there are a number of ways to resolve the issue, but I won't bow to this 'workaround' mentality unless 'bugs' such as these do in fact turn out to be the intended behaviour of the language.

Danny Gregory
BSc Computer Science - UG
University of Southampton
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 22nd Mar 2006 10:56
Added additional text to the help to clarify this:

ENDFUNCTION:
EXITFUNCTION:
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.

"Small, smart, and running around the legs of dinosaurs to find enough food to survive, bedroom programmers aren't extinct after all "
The klited Judge Dredd
8
Years of Service
User Offline
Joined: 20th Apr 2015
Location:
Posted: 22nd Apr 2015 07:32
strange as i get this
Command out of place at line 139.

with this code

function moveplayer()
if upkey()=1
playerspeed(player) = playermaxspeed(player)*1
ENDIF
if downkey()=1
playerspeed(player) = playermaxspeed(player)*-1
ENDIF
curangle = playerangle(player)
if leftkey()=1 and playerspeed(player)>0
playerangle(player) = curangle +5
if playerangle(player) >360
playerangle(player) = 5
ENDIF
if leftkey() = 1 and playerspeed(player)<0
playerangle(player) = curangle -5
if playerangle(player) <0
playerangle(player) = 355
endif
ENDIF
if rightkey()=1 and playerspeed(player)>0
playerangle(player) = curangle -5
if playerangle(player)<0
playerangle(player) = 355
endif
ENDIF
if rightkey() = 1 and playerspeed(player)<0
playerangle(player) = curangle +5
if playerangle(player) >360
playerangle(player) = 5
endif
endif
ENDFUNCTION
line 139 is ENDFUNCTION
is there something missing in the function(if there is i can't find it)
or is it a bug

crimes: stupidity sentence: haggis
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Apr 2015 10:36
Indent your code and it will make it easier to read and find bugs.



It looks like you missed an ENDIF here:



Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-04-19 15:32:36
Your offset time is: 2024-04-19 15:32:36