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 / how do you link two commands?

Author
Message
foozle my moose
19
Years of Service
User Offline
Joined: 23rd Jun 2005
Location:
Posted: 24th Jun 2005 05:56
How do you check two IF statements together, and then both being true print a result. Can you do this to ELSE statements as well?
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 24th Jun 2005 10:25
foozle my moose,

There are a few ways, depending on exactly what you are needing. To simply check two IF statements together, just nest one statement in the other.

Psuedo:


Also, an IF statement with a nested IF THEN statement within it is possible.

Psuedo:


Now, an example of an IF ELSE statement with a nested IF THEN and IF statement within it.

Psuedo:


Without experimentation, I believe you can even nest IF THEN statements within side eachother.

Psuedo:


Don't forget the AND and OR logical operators.

Psuedo:


Simply, learn the concept of the ability to nest statements within statements. There are many more ways to nest if statements within eachother, and how you use them will depend on your programs' needs. If you have an if statement, which will hold within itself(master) another if statement(slave), remember that the 'master' statement's endif command must be the 'closer', the one at the bottom of the entire if statement.


+NanoBrain+
gpex
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 24th Jun 2005 10:32
i hope this helps...



this should get the job done...


-gpex-

PS: for the ELSE commands you would just put another if statement under the else...reply if you dont understand.

Your signature has been erased by a mod because it is larger than 600x120...
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 24th Jun 2005 11:30
or this for a shorter method


Making better games everday!
Oh yeah and just so you know its Oh-nek-a not One-ka!
foozle my moose
19
Years of Service
User Offline
Joined: 23rd Jun 2005
Location:
Posted: 25th Jun 2005 05:22
Doing as NanoBrain said, I now get a nesting error. Here is my code:

rem a$ is a verb that the user inputs
rem b$ is a noun that the user inputs
deadhand:
Print "there is a dead hand here!"
input a$
input b$
if a$= "examine"
if b$= "hand" then Print "its a dead hand!"

Whats up?
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 1st Jul 2005 14:05
Gona need more than that, the ifs and endifs else statements, maybe the whole section of code would help.


Current Projects: SHADE - Game Maker | Mecho - TGC Puzzle Entry | Halo Physics Engine | COLD - Polygonal Collision Detection
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 1st Jul 2005 17:01 Edited at: 1st Jul 2005 17:01
foozle my moose

The code below, of yours, is missing the endif part of the if statement. Therefore, the if a$ = "examine" if statement never closes, or ends.



It should be:



+NanoBrain+
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 2nd Jul 2005 06:33 Edited at: 2nd Jul 2005 06:42
I hate to tell you this foozle my moose... but if your making a text adventure game like the old Infocom text adventures you'd be better off using arrays for everything and select case statements... not 10,000 if statements and gotos for every item. I haven't made a text adventure for Darkbasic yet but i'm going to soon. I threw this code together to give you an idea of how to do it. It's better to load all the data from files (but again I just threw this together). Hope this helps ya.

Also its better to put EXAMINE in the same area as LOOK (as in LOOK AT HAND")... but I didn't do that here because there's no "look" code yet.

Login to post a reply

Server time is: 2024-09-23 23:29:13
Your offset time is: 2024-09-23 23:29:13