BBS: Inland Empire Archive Date: 12-22-92 (12:22) Number: 392 From: DIK COATES Refer#: NONE To: DON WOOD Recvd: NO Subj: Re: Uper/lower case Conf: (2) Quik_Bas
>>>> QUOTING Don Wood to All <<<< DW> I'm new to quick basic and I need a routine that will Bein' a rookie once myself, will give you a couple of solutions for you to think about a bit... Others on the board will likely offer solutions using UCASE$ and LCASE$ functions, so I will avoid that approach... Here Goes: - - - - - - - - - - - Cut on Dotted Line - - - - - - - - - - - - DECLARE SUB ClearKBD () DECLARE SUB ClearScr () '===== Here's one approach to the problem... you'll likely get several ' replies using UCASE$() so will skip that one LOCATE 25, 30 'use locate and terminate string with ';' to reduce .exe size PRINT "Press <ANY> Key to Continue"; DO CALL ClearKBD 'flush keyboard buffer to prevent accidental input DO a$ = INKEY$ LOOP UNTIL LEN(a$) CALL ClearScr 'use procedure if more than a couple of CLS in program 'the way BASIC is written, it actually saves code to 'call as a procedure... Same note applies to ClearKBD 'and you can put them in a library and not have to 'write them again... LOCATE 25, 30 'use locate and terminate string with ';' to reduce .exe size PRINT "Press <Esc> Key to Exit"; temp% = INSTR(" aAbBcCdD", a$) \ 2'note leading blank space and integer div LOCATE 12, 20 SELECT CASE temp% CASE 1 PRINT "The letter you selected was either A or a"; CASE 2 PRINT "The letter you selected was either B or b"; CASE 3 PRINT "The letter you selected was either C or c"; CASE 4 PRINT "The letter you selected was either D or d"; CASE ELSE IF ASC(a$) <> 27 THEN BEEP PRINT "The letter you selected was something else"; END IF END SELECT LOOP UNTIL ASC(a$) = 27 '===== Another approach to the problem DO CALL ClearKBD 'flush keyboard buffer to prevent accidental input DO a$ = INKEY$ LOOP UNTIL LEN(a$) CALL ClearScr 'use procedure if more than a couple of CLS in program LOCATE 25, 30 'use locate and terminate string with ';' to reduce .exe size PRINT "Press <Esc> Key to Exit"; 'temp% = ASC(a$) OR 32 converts ascii value to lower case temp% = ASC(a$) AND 223 'converts ascii value to upper case LOCATE 12, 20 SELECT CASE temp% CASE 65 '97 commented out value is for lowercase and using OR Boolean Op PRINT "The letter you selected was either A or a"; CASE 66 '98 PRINT "The letter you selected was either B or b"; CASE 67 '99 PRINT "The letter you selected was either C or c"; CASE 68 '100 PRINT "The letter you selected was either D or d"; CASE ELSE IF ASC(a$) <> 27 THEN BEEP PRINT "The letter you selected was something else"; END IF END SELECT LOOP UNTIL ASC(a$) = 27 END SUB ClearKBD DO LOOP WHILE LEN(INKEY$) END SUB SUB ClearScr CLS END SUB - - - - - - - - - - - Cut on Dotted Line - - - - - - - - - - - - Trusting the above helps cloud the issue... Season's Greetings and regards Dik, Oshawa, Canada ... Remember Taglines at Christmas... a gift for every occasion -Dik ___ Blue Wave/QWK v2.10 --- Maximus 2.00 * Origin: Durham Systems (ONLINE!) (1:229/110)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET