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 / This is probably REALLY stupid but...

Author
Message
the RED moriLLa
18
Years of Service
User Offline
Joined: 22nd Jan 2008
Location:
Posted: 17th Apr 2008 22:41
I am having trouble understanding Sub Routines, they don't seem to work for me. Well the code works but "return" never works.

Here is my code:



Whenever I try and compile the code I get an error "Could not close nest at line 52" and I have no freakin' clue what that means.

Sorry for being such a noob

But thanks anyway,
grei J.

:RED:
Link102
21
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 18th Apr 2008 00:40
1) "repeat" needs the "while" command, just like "do" needs "loop",

2) I also saw that the "character stats" bit is the same every loop you should put above the "do" command,

3) put "sync on : sync rate 30" on the top of your program and "sync" just above "loop", this will make your program run very smooth.

Not_Maindric
18
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 18th Apr 2008 01:04
Before the return, put in "Until ..."

... is where you put the condition. If that condition is met, the it will go to return.

LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 18th Apr 2008 01:24
Here is a working version. There are a few edits that I made. Please compare this to what you had. Personally, I think 30 fps is slow; I normally use 60 fps, but in this case 60 is too fast.



Quote: "Sorry for being such a noob "

We all had to learn and there is no reason to apologize for being new. The problems enter in when a newbie disregards/doesn't read the AUP and/or stickies and does exactly what they were instructed no to.

Quote: "1) "repeat" needs the "while" command"

Actually, it's REPEAT - UNTIL, he he you can also use WHILE - ENDWHILE. In your code, you jumped to the subroutine and then coded repeat without an until. You really didn't need the repeat there, as your code repeatedly goes to the subroutine. I would strongly advise against coding a repeat - until loop waiting for input from the user for most games, as there likely will be other things happening in your game once it is more developed. For example, if you are moving some shots across the screen, they would stop while waiting for the user to press a key. The rest of the things you can probably figure out on your own - if you have more questions, just post [caution: learn to use the search button and be prepared to look diligently to find answers before you post - otherwise you may get flamed.]

Hope this helps,
LBFN
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Apr 2008 04:13 Edited at: 19th Apr 2008 04:20
And...

Check these out:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

(Number 2 covers all the points you were asking about).

Quote: "Could not close nest at line 52"


This is the number one reason why you should indent your code correctly. You have indented, but it's far from correctly done.

When done correctly (how to is covered in the tutorials linked to above), then the first and last lines of code in your program will start at the left edge of the screen.

If the last line isn't, then you know you have a nesting problem.

Your last line does, but only because you've only partially indented the code. If proper indentation is used it should let you see at a glance where you've missed something out.

TDK_Man

the RED moriLLa
18
Years of Service
User Offline
Joined: 22nd Jan 2008
Location:
Posted: 19th Apr 2008 16:22
Wow! Okay thanks everybody this helps alot.

Link102-Actually didnt mean to have "repeat" there, it should have been deleted... I was experimenting and didnt clean up properly

LBFN-Thanks for that man, it looks so clean now! Ill keep that for reference in the future, for code "structure" and all

HAHA! And I wont be sorry anymore

TDK-Thanks for the tuts man... But Im already reading them They are great btw, very very helpful!

Thanks all, Ill keep playing with the code and clean it up more, then post it again later

Thanks
grei J.

:RED:
the RED moriLLa
18
Years of Service
User Offline
Joined: 22nd Jan 2008
Location:
Posted: 19th Apr 2008 16:27
Another question...

TDK- After the loop is done



if you "Gosub" out to a subroutine of function do you basically do the same thing inside those blocks of code?



...HAHA! I think I just answered my own question

grei J.

:RED:

Login to post a reply

Server time is: 2026-07-05 14:20:47
Your offset time is: 2026-07-05 14:20:47