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.

Newcomers DBPro Corner / Need some quick help

Author
Message
May0naise
15
Years of Service
User Offline
Joined: 16th Nov 2008
Location: Lost in Time
Posted: 28th Apr 2010 03:04
Well im trying to learn BASIC again. Havent used it in awhile and pretty much forgot it all. Doing this tutorial, and im stuck. Here's my code:



in line 2
Quote: "if Button(240,200,"New Game")=1 then goto New_Game"

When i click compile and run the line is highlighted and the code doesnt continue. Im sure it means its an error, but i have no clue whats wrong with it.

Thanks in advance.

Who you chose to be around you, lets you know who you are.
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 28th Apr 2010 05:03
you don't need those "endif" statements. if-then doesn't require an endif. I'm not sure if it's a runtime or a compile time error by what you've said, but i'm pretty sure it's compile time. Basically, the if/then thing is already closed as far as the compiler is concerned, so you're trying to end another if.


zeroSlave
15
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 28th Apr 2010 05:13 Edited at: 28th Apr 2010 05:20
The endifs and your function isn't returning a value. Your function needs to end like: "ENDFUNCTION pressed"



My green thumb grew the tree my Trojan War horse was crafted from. With roses in our pockets we rally round the tombstones. Ashes to ashes, we all fall down.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Apr 2010 18:03 Edited at: 28th Apr 2010 18:04
At the risk of being rude, I wouldn't trust any tutorial which uses Goto without explaining why it shouldn't be used - as it shows a lack of programming experience.

And, assuming that the Endifs aren't an error on your part, I'd scrub that source of tutorials off your 'must read' list.

I do firmly believe that there are far too many very poorly written and therefore damaging so-called tutorials out there.

Obviously I have to declare an interest as I put a lot of time and effort into writing them myself so it's annoying when people like you are being led astray by bad tutorials.

Don't get me wrong, there are lots of excellent tutorials out there written by lots of people.

It's just the few bad ones like the one you have encountered - which is wrong on so many levels - that give all tutorial writers a bad name.

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

TDK

May0naise
15
Years of Service
User Offline
Joined: 16th Nov 2008
Location: Lost in Time
Posted: 28th Apr 2010 21:49
@cough:
Thanks, can you explain why i need pressed after ENDFUNCTION?


@TDK
Ive been through your tutorials =] and they do help alot, i was checking out other peoples tutorials

Who you chose to be around you, lets you know who you are.
zeroSlave
15
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 28th Apr 2010 22:05 Edited at: 28th Apr 2010 22:07

is looking for a return value from the function. If you just ENDFUNCTION, nothing is returned. "Pressed" is the variable that you are changing inside the function:



So you would want to return that variable when the function ends "ENDFUNCTION Pressed"




If instead you put:


You would have to change the code where you call the function to:


I hope my explanation isn't too confusing.

My green thumb grew the tree my Trojan War horse was crafted from. With roses in our pockets we rally round the tombstones. Ashes to ashes, we all fall down.
May0naise
15
Years of Service
User Offline
Joined: 16th Nov 2008
Location: Lost in Time
Posted: 28th Apr 2010 22:46 Edited at: 28th Apr 2010 22:46
Hypothetically:
If the code was..


Then the code would have..


?

Who you chose to be around you, lets you know who you are.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Apr 2010 23:29
Yes - that's correct... but only if you want to return that value (Clicked) from the function.

If you didn't need it, you wouldn't return it.

Quote: "Ive been through your tutorials"


Then they can't be all that good as all this is covered in the one on Functions!

TDK

May0naise
15
Years of Service
User Offline
Joined: 16th Nov 2008
Location: Lost in Time
Posted: 29th Apr 2010 02:07 Edited at: 29th Apr 2010 02:08
Thanks

Haha well i havent been through them in a year or so..trying to reteach myself along with some help

Who you chose to be around you, lets you know who you are.

Login to post a reply

Server time is: 2024-09-28 16:37:05
Your offset time is: 2024-09-28 16:37:05