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 SuperBASIC
130 case$ = "" : REMark "a" == "A" - both cases
140 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 SELect
230 :
2000 REMark In SMSQ/E S*BASIC
2010 REMark Note: MANIFEST is optional TURBO command for extra constant checking
2020 :
2030 MANIFEST : _a =  97 : A_ = 65
2040 MANIFEST : _b =  98 : B_ = 66
2050 MANIFEST : _c =  99 : C_ = 67
2060 MANIFEST : _d = 100 : D_ = 68
2070 MANIFEST : _e = 101 : E_ = 69
2080 MANIFEST : _f = 102 : F_ = 70
2090 MANIFEST : ENTER = 10 : Esc = 27
2100 CLS
2110 REPeat loop
2120 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 case
2150 = _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 loop
2220 = REMAINDER : PRINT 'Try again'
2230 END SELect
2240 END REPeat loop
2250 PRINT 'Test complete'
2260 PRINT #0,'Test complete'

Michael
_______________________________________________
QL-Users Mailing List

Reply via email to