If we are talking about Selecting on single-character strings, such as when 
coding actions depending on some keypress, I would like to tell you about how I 
get around this problem.  At the very beginning, I would declare some constants 
of the codes of all the alphabetical characters, all 52 of them.  Underscores 
are used in the names to highlight these vars are constants and their initial 
values should not change.  I will give what the code would look like under 
Minerva, and then how this would look in SMSQ/E. Note that when Selecting on 
strings, both cases, capitals and lower case letters are considered equivalent. 
 This has to be taken into account.
100 : 
110 :120 REMark In Minerva SuperBASIC130 case$ = "" : REMark "a" == "A" - both 
cases140 SELect ON case$150 = "a" : PRINT 'Choice is "A"'160 = "b" : PRINT 
'Choice is "B"'170 = "c" : PRINT 'Choice is "C"'180 = "d" : PRINT 'Choice is 
"D"'190 = "e" : PRINT 'Choice is "E"'200 = "f" : PRINT 'Choice is "F"'210 = 
CHR$(27) : PRINT 'Esc pressed'220 END SELect230 :2000 REMark In SMSQ/E 
S*BASIC2010 REMark Note: MANIFEST is optional TURBO command for extra constant 
checking2020 :2030 MANIFEST : _a =  97 : A_ = 652040 MANIFEST : _b =  98 : B_ = 
662050 MANIFEST : _c =  99 : C_ = 672060 MANIFEST : _d = 100 : D_ = 682070 
MANIFEST : _e = 101 : E_ = 692080 MANIFEST : _f = 102 : F_ = 702090 MANIFEST : 
ENTER = 10 : Esc = 272100 CLS2110 REPeat loop2120 PRINT 'Choose case: Press a 
letter between "a" and "F" ';2130 case = CODE(INKEY$(#1,-1)) : IF case <> ENTER 
: PRINT CHR$(case); " ";2140 SELect ON case2150 = _a,A_ : PRINT 'Choice is 
"A"'2160 = _b,B_ : PRINT 'Choice is "B"'2170 = _c,C_ : PRINT 'Choice is 
"C"'2180 = _d,D_ : PRINT 'Choice is "D"'2190 = _e,E_ : PRINT 'Choice is 
"E"'2200 = _f,F_ : PRINT 'Choice is "F"'2210 = Esc   : PRINT 'Esc pressed' : 
EXIT loop2220 = REMAINDER : PRINT 'Try again'2230 END SELect2240 END REPeat 
loop2250 PRINT 'Test complete'2260 PRINT #0,'Test complete'
Michael
_______________________________________________
QL-Users Mailing List

Reply via email to