help

New to FreeBASIC? Post your questions here.
Post Reply
dbrf
Posts: 2
Joined: Jan 11, 2009 4:15

help

Post by dbrf »

I cant figure out what they mean about type mismatch

Code: Select all

Dim as string game1,game2,game3,game4,game5,answer,score
Print "welcome to jeopardy"
Print "first thing to do is choose which game"
Print "game1,game2,game3,game4,game5"
Do
input answer
answer = LCase$(answer)
loop until answer = "game1" or answer = "game2" or answer = "game3" or answer = "game3" or answer = "game5"
if answer = "game1" Then
Goto game1 
game1:
print 
print "category: American history"
print "100: In the American civil war what were the southerns name?"
print "a: Who were the Union"
print "b: Who were the Confederates"
print "c: Who were the axis"
print "d: who were the UNA"
Do
input answer
loop until answer = "a" or answer = "b" or answer = "c" or answer = "d"
if answer = "b" Then
score = score+100
else Then
    score = score -100
print score
sleep 
endif
end
endif
endif
endif
aleofjax
Posts: 117
Joined: Oct 18, 2007 8:10

Post by aleofjax »

Okay, your main problem was that your score value was a string. You could use a string, but an integer seems much more appropriate. For strings, you would have to use other functions to translate it into useable numbers. (see val(), str() ) You can print integers just like strings.

You also need to pay attention to your IF ... END IF blocks. the END IF must come directly after the conditional instructions. See below:

Code: Select all

dim As String game1,game2,game3,game4,game5,answer
dim As integer score

Print "welcome to jeopardy"
Print "first thing to do is choose which game"
Print "game1,game2,game3,game4,game5"

Do
    input answer
    answer = lcase$(answer)
loop Until answer = "game1" Or answer = "game2" Or answer = "game3" Or answer = "game3" Or answer = "game5"

If answer = "game1" Then
    goto game1 
End If

game1:
Print 
Print "category: American history"
Print "100: In the American civil war what were the southerns name?"
Print "a: Who were the Union"
Print "b: Who were the Confederates"
Print "c: Who were the axis"
Print "d: who were the UNA"

Do
    input answer
loop Until answer = "a" Or answer = "b" Or answer = "c" Or answer = "d"

If answer = "b" Then
    score = score+100
Else 
    score = score -100
End If

Print score
Sleep 
End
Have a good day! ^_^
dbrf
Posts: 2
Joined: Jan 11, 2009 4:15

Post by dbrf »

Thank you very much and have a great day to
Post Reply