Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Again Help Chapter 2
#1
So let me show a demo

HP= 0
PRINT " A MONSTER APPEARD"
PRINT
PRINT (1) GERMAN SUPLEX
INPUT X
IF X = 1 THEN HP = 0

what i want is if people press other then 1 i wanna put "ERROR" and then put back to PRINT (1) GERMAN SUPLEX
Reply
#2
The best way to do this type of thing is with some type of INPUT VALIDATION loop.   Let me share simple demo for you:


HP = 0
DO
    PRINT " A MONSTER APPEARD"
    PRINT
    PRINT "(1) GERMAN SUPLEX"
     INPUT X
     IF X <> 1 THEN PRINT "ERROR -- INVALID CHOICE"
LOOP UNTIL X = 1
IF X = 1 THEN HP = 0

DO....  LOOP UNTIL.... the input variable is in the proper range to be valid
Reply
#3
THANKS SIRE WILL TEST IT OUT Big Grin
Reply
#4
Hi BloodyHash. 

Will your program have a menu with more Choices/Options? Will the user/player chose by number or by typing out the word? 

That's a good idea to have an error trap routine on the menu choices.
Reply




Users browsing this thread: 1 Guest(s)