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.

Author
Message
Odin The Great
20
Years of Service
User Offline
Joined: 2nd Mar 2004
Location:
Posted: 6th Mar 2004 23:39
What do you put after then?

For example:

if spacekey()> then Health=Health+25

After the Health+25, if I wanted to put Potions=Potions-1 what would I put? I tryed using two thens but it wont let me.

Looking for newbie DBpro programmers to learn with e-mail me if your interested!
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 6th Mar 2004 23:49 Edited at: 6th Mar 2004 23:51
Okay, the IF statement has two syntax options. IF/THEN and IF/[ELSE]/ENDIF you can use either one, but don't mix them.

IF A > B then PRINT "A Wins!": gosub EndGame

That was a complete IF/THEN statement. The colon allows for multiple statements to be included in the execution 'block'.

IF A > B
PRINT "A Wins!"
gosub EndGame
ENDIF

Same thing, but the execution 'block' is between IF and ENDIF. IF/ENDIF also has an option ELSE statement.

IF A > B
PRINT "A Wins!"
gosub EndGame
ELSE
PRINT "A has not won, keep on playing?"
ENDIF

Also, watch out for this... it will generate a syntax error because the compiler does not know where the ENDIF goes since the IF was associated with the THEN keyword.

IF A > B THEN
PRINT "A Wins!"
gosub EndGame
ENDIF


Clear as mud?
--
TAZ

Odin The Great
20
Years of Service
User Offline
Joined: 2nd Mar 2004
Location:
Posted: 7th Mar 2004 00:00
Clear as water..

Looking for newbie DBpro programmers to learn with e-mail me if your interested!
Saikoro
21
Years of Service
User Offline
Joined: 6th Oct 2003
Location: California
Posted: 7th Mar 2004 08:21
IF trigger
result
ENDIF

Trigger is what you want to trigger the IF.

The result is exactly what it says. Whatever code you want as a result. You can have multiple lines of code in the result if you like.

ENDIF ends the IF.

Good job Zircher at explaining it in detail, but there are some newer, simpler minded people at the NC forums that I have encountered that may stumble upon this and have no idea what you are saying.

Hope this helps.

-Vash the Stampede

Intel Pentium 4 3.0 Ghz 1024MB Ram NVIDIA GeForceFX 5200 128MB 19" LCD DVI Viewsonic

Login to post a reply

Server time is: 2024-11-26 07:41:30
Your offset time is: 2024-11-26 07:41:30