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 / GOSUB - Basic - What is problem whit my code?

Author
Message
Kikkeli
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 23rd Feb 2004 20:59 Edited at: 23rd Feb 2004 21:02
Hello,

I have problem whit my code, can someone help me

GOSUB SYNTAX is something like that:



right?

And there is my code:



, Thank you for help and tips.

DBP43V3R
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 23rd Feb 2004 21:07 Edited at: 23rd Feb 2004 21:09
You don't put a colon ( after the parameter on return. So...

NOT - gosub sub:
YES - gosub sub

Also, this isn't good...



All gosub commands need a return, else you get muddled up.
Instead use something like...



END ends the program straight away, so you don't have to wait for it to run to the end of the code .

P.s. Use the code button at the top in the future for code, it makes it easy to see apart from your other writing. Just highlight the code and press it .

EDIT: Oh you have now .

Also just noticed... use this...



I recommend you look at my tutorial, it's on the newcomers forum, stickied at the top. It covers basic syntax.

Trying is the first step towards faliure.
The Basics of DBPro Tutorial, on my site now!
Athelon XP 1600 Plus (1.4ghz) - ATI Radeon 9600 Pro - 256mb RAM
Kikkeli
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 23rd Feb 2004 21:42
Well, thank you for the help. This time i got my code compiled, but it doesn't still work like i want:

[IN FULL SCREEN]
WHAT YOU WANT TO DO? WRITE GO OR WRITE QUIT:
-> GO
Press any key to QUIT
-> Any key
... and then it ends.

I don't understant why it takes wrong IF...


DBP43V3R
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 23rd Feb 2004 22:11
instead of this Total put this Total$ a string variable.

so the code it supposed to be like this

PRINT "WHAT YOU WANT TO DO? WRITE GO OR WRITE QUIT:"
INPUT Total$

IF TOTAL$ = "QUIT"
PRINT "Press any key to QUIT"
WAIT KEY
END
ENDIF

IF TOTAL$ = "GO"
PRINT "Are you sure you want to GO?"
WAIT KEY
GOSUB WOW
ENDIF

WOW:
PRINT "WOW, we are in sub called WOW. Press any key"
WAIT KEY

PRINT "Write BACK"
INPUT BACK

IF BACK$ = "BACK"
RETURN
ENDIF


I think that shuld work!

CURRENT PROJECT: RETRO PAC-MAN
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 25th Feb 2004 01:16 Edited at: 25th Feb 2004 01:17
There's was another problem and I make some changes


PRINT "WHAT YOU WANT TO DO? WRITE GO OR WRITE QUIT:"
INPUT Total$

IF TOTAL$ = "QUIT" or TOTAL$ = "quit"
PRINT "Press any key to QUIT"
WAIT KEY
END
ENDIF

IF TOTAL$ = "GO" or Total$="go"
PRINT "Are you sure you want to GO?"
WAIT KEY
GOSUB WOW
ENDIF

WOW:
PRINT "WOW, we are in sub called WOW. Press any key"
WAIT KEY

PRINT "Write BACK"
INPUT BACK$

IF BACK$ = "BACK" or Back$="back"
RETURN
ENDIF

CURRENT PROJECT: RETRO PAC-MAN
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 25th Feb 2004 01:56
Do subroutines work if you run them outside of loops? Honestly, try reading the manual.
Kikkeli
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 26th Feb 2004 17:10
comando 300, thank for the help! I love you .

And sponge008... honestly, try reading the manners. This is newscorner so why wouldn't i ask help here? And i have read manuals, but it is not just my fault if my code don't work (I have DarkBasic Pro -tutorial and Beginners Guide to The Darkbasic). And if you don't want to help, then you can be quiet.

DBP43V3R
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 26th Feb 2004 18:22
To simplify your logic, try this...


IF upper$(TOTAL$) = "QUIT"
PRINT "Press any key to QUIT"
WAIT KEY
END
ENDIF

The upper$ command returns your string as all upper case and makes it easier to match the literal string part of the IF statement.
--
TAZ

Login to post a reply

Server time is: 2024-11-26 05:25:52
Your offset time is: 2024-11-26 05:25:52