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 / Syntax / Nesting error

Author
Message
JAW_THE_KILLER
13
Years of Service
User Offline
Joined: 23rd Feb 2011
Location:
Posted: 23rd Feb 2011 20:44
Ok, I must be retarded or something, because I cannot find the nesting error in my code. Please help this sorry noob.

hide mouse

make object plain 101,5000,5000
xrotate object 101,270

color object 101,rgb(200,0,0)

make object box 201,100,100,100

do
gosub _control
gosub _exit
loop

end

_control:

if keystate(203)=1
move object 201,10
if keystate(200)=1
yrotate object 201,wrapvalue((object angle Y(201)) - 5)
if keystate(205)=1
yrotate object 201,wrapvalue((object angle Y(201)) + 5)
endif

return

_exit:

if Inkey$()="q"
cls : END
endif

return

you are what you eat, and I eat noobs, so...
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 24th Feb 2011 00:19 Edited at: 24th Feb 2011 00:23
Hello JAW,
Let me be the first to welcome you to the forums and the DBC board.

When posting code please put it in a code box (the simplest way to do this is to highlight your code and click the code button).


I've indented your code for you - if you post in code boxes your indenting will be maintained but post in normal text and the forum will "correct" your spacing.

You must close every IF with an ENDIF, unless you use IF... THEN... which tells DB that it's a one line IF statement: everything on that line is part of the statement and the statement ends when the line ends.

Now the code is indented you can clearly see where the missing ENDIF's should be in the _control subroutine, the indentation gradually steps in then jumps out three levels! We need ENDIF's to breach the gap and close those IF statements.

Good on you for using subroutines so early by the way , I ignored them for far too long!


Everything worthwhile requires effort.
JAW_THE_KILLER
13
Years of Service
User Offline
Joined: 23rd Feb 2011
Location:
Posted: 24th Feb 2011 20:01
Thanks for the help, it's working just fine now! And thanks for telling me how to use the buttons.

you are what you eat, and I eat noobs, so...

Login to post a reply

Server time is: 2024-04-19 02:12:37
Your offset time is: 2024-04-19 02:12:37