Glock
New Member
Posts: 13
|
Post by Glock on Apr 21, 2023 9:33:18 GMT -5
Hi All
I am working through Carl's Beginning Programming with Liberty Basic. This is one of the HI - LO examples using GOSUB. For some reason I cannot get it to work properly - it keeps asking for a higher number. I cannot find my mistake if I have made one. Can anyone help?
Best regards
Robert
[start]
guessMe = int(rnd(1)*100+1)
print "HI - LO"
print
print "Choose a number - beat the computer!"
print
[ask]
input "What is your guess?"; guess
count = count + 1
if guess = guessMe then
gosub [announceWin]
input "Play again (y/n)"; play$
if play$ = "y" then [start]
print "Press ALT + F4 to close this window."
end
else
gosub [giveHint]
end if
goto [ask]
[announceWin]
print "You win. It took "; count; " guesses!"
guess = 0
count = 0
return
[giveHint]
if geuss < guessMe then
print "Guess higher."
else
print "Guess lower."
end if
return
end
|
|
|
Post by tenochtitlanuk on Apr 21, 2023 10:20:27 GMT -5
Looks like a simple spelling error- you put 'geuss' in
if geuss < guessMe then ...and should be 'guess'.
|
|
Glock
New Member
Posts: 13
|
Post by Glock on Apr 21, 2023 11:40:35 GMT -5
Thanks very much for that.
|
|