if instr("LMlm",LM$)=0 then cls goto 20 endif
It's not a great idea to use multi-statement lines that begin with an IF statement. There is the danger that commands may not do what you expect! Far better to make use of ELSE and ENDIF simply because they are available and make your code much clearer. When someone is entering keyboard commands you need to make sure that the character case will be detected or nothing will happen - and you'll have a confused user! So: 32 LM$ = UCASE$(LM$) will make sure that your string comparisons will work, even if they enter lower or mixed case characters. INSTR() is a great function for this sort of thing. It will search the test string and return the position of the search string or zero if it's not found. In the above example it will return 1 for "L", 2 for "M", 3 for "l" or 4 for "m". Or you could use the full IF/ENDIF tree with slight rearrangement: 20 CLS 22 PRINT:PRINT 24 PRINT" L FOR LATH OR M FOR MILL" 25 PRINT : PRINT 30 INPUT" L OR M" ;LM$ 32 LM$ = UCASE$(LM$) 35 PRINT : PRINT IF LM$ = "L" then 'do something with the lathe ELSE IF LM$ = "M" then 'do something with the mill ELSE GOTO 20 ENDIF
Jumping out of the IF/ENDIF with a GOTO is a bit naughty (it used to mess the return stack up), but MMBasic is quite well behaved. :) |