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 / If statement analysing an input

Author
Message
Chaosmatt
12
Years of Service
User Offline
Joined: 3rd May 2012
Location:
Posted: 11th Jun 2016 20:21
Ok so my issue is, I have looked and even copied how an if statement should analyse an input and I get the logic of an if statement. No matter how I try I cannot seem to get it to work and constantly end up with the error message "IF condition only takes one parameter at line ...."

I have looked at the darkbasic help in the application, various web resources and searched the forum but haven't found the answer yet.

So here is the code, please tell me what I'm doing wrong.

if ;Answer$ = "THEANSWER" exit

I will copy the entire code if required.

I have also tried without the quotation marks

This has become extremely frustrating for me, so any help will be appreciated.

Thank you
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 11th Jun 2016 21:16
Remove the semicolon and add then before exit.

if Answer$ = "THEANSWER" then exit
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 12th Jun 2016 05:58 Edited at: 12th Jun 2016 06:01
Not sure if dbpro even uses semi colons, I know you can use a colon though. Semi colons are used to use two commands on 1 line.

if is a command, answer$ is a variable does no good to use a colon, essentially making it into

"if
answer$"
it leaves the if statement blank

`theses work
if Answer$ = "THEANSWER"
exit
endif
or if Answer$ = "THEANSWER" then exit
or with a colon even. if Answer$ = "THEANSWER" :exit :endif
A child's dream never dies.





WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 12th Jun 2016 15:02 Edited at: 12th Jun 2016 15:04
A semi-colon is used in a print statement to concatenate a string constant with a variable or different variables types.

age = 8
Print "Lucy is ";age;" years old."
Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 14th Jul 2016 03:38
You can terminate lines with them though it is not required as it is in most languages
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 17th Jul 2016 18:03
Is there some kind of quantum fluctuation on this forum causing people who post here to zap out of existence?

Login to post a reply

Server time is: 2024-11-23 14:57:54
Your offset time is: 2024-11-23 14:57:54