Suggestions

by (Login burger2227)
R

Move line 50 down to the level INPUT. I already told it my name if I play again. I would use a DO LOOP instead. Place DO where line 50 is and put LOOP UNTIL UCASE$(yn$) = "N" where the IF yn$ = "N" THEN is. Actually only a N answer will keep it from quitting if you want.

Using THEN with a line number is the same as using THEN GOTO 50. Loops organize the code into separate code areas too. Like IF blocks.

UCASE$ capitalizes string entries so that you don't need:

IF yn$ = "Y" OR yn$ = "y" THEN

You could just capitalize the result of the INPUT: yn$ = UCASE$(yn$)

But what if an entry is not Y or N? Simple! Add a loop around the INPUT:

DO
COLOR 14: LOCATE 23, 20: INPUT "Do you want to play again(Y/N):"; yn$
LOCATE 23, 20: PRINT SPACE$(40) ' clears input line
yn$ = UCASE$(yn$) ' capitalize
LOOP UNTIL yn$ = "Y" OR yn$ = "N" ' limit answer to Y or N



    
This message has been edited by burger2227 on Nov 21, 2009 11:15 PM

Posted on Nov 21, 2009, 10:47 PM

Respond to this message   

Return to Index