Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

TrueBasic - why is this not working?

weedude999weedude999 Posts: 1Member
Sorry for the lack of comments, Im just fiddling around with this program that I am going to have to write in class tomorrow... At the bits highlighted in blue I get the error "must be a number"
all help is appreciated.



LOCAL difficulty$, guess, integer

DECLARE DEF higher_or_lower

DO
INPUT PROMPT ("Would you like to play guess number on easy, medium or hard?"): difficulty$
Select Case difficulty$
Case "easy"

RANDOMIZE
LET integer = int(20*rnd)
DO
DO
INPUT PROMPT ("Guess a number between one and twenty") : guess
LOOP UNTIL guess => 0 AND guess <= 20
CALL higher_or_lower (guess, integer)
LOOP UNTIL guess = integer

Case "medium"
RANDOMIZE
LET integer = int(50*rnd)
DO
DO
INPUT PROMPT ("Guess a number between one and fifty") : guess
LOOP UNTIL guess => 0 AND guess <= 50
CALL higher_or_lower (guess, integer)
LOOP UNTIL guess = integer

Case "hard"
RANDOMIZE
LET integer = int(100*rnd)
DO
DO
INPUT PROMPT ("Guess a number between one and a hundred") : guess
LOOP UNTIL guess => 0 AND guess <= 100
CALL higher_or_lower (guess, integer)
LOOP UNTIL guess = integer

CASE ELSE
PRINT "Error. Try again."
End SELECT
LOOP UNTIL difficulty$ = "easy" OR difficulty$ = "medium" OR difficulty$ = "hard"

END

SUB higher_or_lower (guess, integer)
SELECT CASE guess
[color=Blue]CASE IS < integer[/color]
PRINT "The number is higher. "
[color=Blue]CASE IS > integer [/color]
PRINT "The number is lower. "
CASE ELSE
END SELECT
END SUB


Sign In or Register to comment.