Posts: 11
Threads: 6
Joined: Jun 2003
Hey i'v read ur tutorials! they're really helpfull!
I understand the IF something = something THEN something command!!
but what if it isn't something! Let me explain!!!
PRINT "Does 2 + 2 = 4 ?"
INPUT answer$
IF answer$ = "yes" THEN PRINT "correct"
IF answer$ = "no" THEN PRINT "incorrect"
END
But what if they were to type in "oogibabble" instead of yes or no? it just conrinues! how can i tell it to go back and ask again if they don't type yes or no??
Please help!
Tom. if u want to e-mail me it's tomlewis86@hotmail.com
Posts: 3,368
Threads: 195
Joined: Jan 2003
ELSE
Or just use GOTO after the answer.
Or select.
I didn't know about ELSE for a long time, actually..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 2,765
Threads: 138
Joined: Nov 2002
Code:
PRINT "Does 2 + 2 = 4 ?"
INPUT answer$
IF answer$ = "yes" THEN PRINT "correct"
IF answer$ = "no" THEN PRINT "incorrect"
END
I do it like this
Code:
PRINT "Does 2 + 2 = 4 ?"
redo:
INPUT answer$
SELECT CASE answer$
CASE "yes"
PRINT "correct"
CASE "no"
PRINT "incorrect"
CASE ELSE
GOTO redo
END SELECT
END
Or
Code:
PRINT "Does 2 + 2 = 4 ?"
redo:
INPUT answer$
IF answer$ = "yes" THEN
PRINT "correct"
ELSEIF answer$ = "no" THEN
PRINT "incorrect"
ELSE
GOTO redo
END IF
END
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 1,813
Threads: 284
Joined: Mar 2003
Code:
IF 2 + 2 = 4 THEN PRINT "true"
IF 2 + 2 <> 4 THEN PRINT "false"
IF "hey" = "hey" THEN PRINT "true"
IF "hey" = "aye" THEN PRINT "false"
IF "hey" <> "aye" THEN PRINT "true"
IF "hey" <> "hey" THEN PRINT "false"
earn.
Posts: 57
Threads: 12
Joined: Mar 2003
I would do like this :
PRINT "Does 2+2=4"
redo:
INPUT answer$
IF answer$<>("yes" or "YES") THEN PRINT "FALSE" : GOTO REDO
PRINT "TRUE"
END
Posts: 57
Threads: 12
Joined: Mar 2003
Sorry , I made a huge mistake .
This one will work perfectly :
PRINT "Does 2+2=4"
redo:
INPUT answer$
IF answer$<>"yes" or answer$<>"YES" THEN PRINT "FALSE" : GOTO REDO
PRINT "TRUE"
END
Posts: 1,813
Threads: 284
Joined: Mar 2003
Quote:This one will work perfectly
Not quite.
Code:
PRINT "Does 2+2=4"
redo:
INPUT answer$
IF LCASE$(answer$) <> "yes" THEN PRINT "FALSE" : GOTO REDO
PRINT "TRUE"
END
earn.
Posts: 3,368
Threads: 195
Joined: Jan 2003
Code:
DIM SHARED choice.amount AS INTEGER
choice.amount = 2
DIM SHARED choice.string$(0 TO choice.amount)
DIM SHARED choice.color(0 TO choice.amount) AS INTEGER
DIM SHARED len.choice(0 TO choice.amount) AS INTEGER, max.len.choice AS INTEGER
DIM SHARED thequestion$, len.thequestion.plus.two AS INTEGER
thequestion$ = "Is 2 + 2 = 4?"
choice.string$(0) = "I don't know!"
choice.string$(1) = "Yes"
choice.string$(2) = "No"
choice.color%(0) = 9
choice.color%(1) = 2
choice.color%(2) = 4
len.thequestion.plus.two = LEN(thequestion$) + 2
FOR I% = 0 TO choice.amount% - 1
temp% = LEN(choice.string$(I%))
IF temp% > max.len.choice% THEN max.len.choice% = temp%
len.choice%(I%) = temp%
NEXT I%
SCREEN 7: CLS
LOCATE 1, 1: PRINT thequestion$
I% = 0
DO
DO: I$ = INKEY$: LOOP UNTIL I$ <> ""
SELECT CASE I$
CASE CHR$(0) + "M", CHR$(0) + "P": I% = I% + 1: IF I% > choice.amount% THEN I% = 0
CASE CHR$(0) + "K", CHR$(0) + "H": I% = I% - 1: IF I% < 0 THEN I% = choice.amount%
CASE CHR$(13): EXIT DO
END SELECT
COLOR choice.color%(I%)
LOCATE 1, len.thequestion.plus.two
PRINT choice.string$(I%) + STRING$(max.len.choice% - len.choice%(I%), " ")
LOOP
IF I% = 1 THEN
FOR I% = 1 TO 200
SOUND 37 + .5 * I% ^ 2, .05
NEXT I%
LOCATE 13, 5
right1$ = "That's right! 2+2=4! Yessir!"
len.right% = LEN(right1$)
c% = 1
FOR I% = 1 TO len.right%
IF c% < 15 THEN c% = c% + 1 ELSE c% = 1
COLOR c%
PRINT MID$(right1$, I%, 1);
NEXT I%
SLEEP 1
LOCATE 20, 1
COLOR 14: PRINT "Please press the officially designated <any key> to continue.";
SLEEP
LOCATE 22, 4:
COLOR 2: PRINT "Any key: pround sponsor of this Useless Program.";
SLEEP
ELSE
col1% = 4
col2% = 12
col3% = 14
col4% = 15
PRINT
DO
COLOR col1%
PRINT "WRONG!";
columns% = columns% + 1
IF columns% = 6 THEN
columns% = 0
t2% = t2% + 1
IF t2% = 4 THEN
t2% = 0
SWAP col1%, col2%
SWAP col1%, col3%
SWAP col1%, col4%
END IF
PRINT
END IF
IF INKEY$ <> "" THEN
EXIT DO
CLS
LOCATE 13, 16
COLOR 4
PRINT "W-R-O-N-G!"
SLEEP
EXIT DO
END IF
LOOP
END IF
SYSTEM
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 2,765
Threads: 138
Joined: Nov 2002
lol :rotfl:
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 199
Threads: 2
Joined: May 2003
Code:
DO
PRINT "Does 2 + 2 = 4 ?"
INPUT answer$
LOOP UNTIL LCASE$(answer$) = "yes" OR LCASE$(answer$) = "no"
IF answer$ = "yes" THEN PRINT "correct"
IF answer$ = "no" THEN PRINT "incorrect"
END
Is another way...
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79]
[/url]
END OF LINE
.