Hello there,
I have a program written that is case sensitive (everything uppercase.)
I was hoping that I could include some code at the top of the program so that everything a user inputs will be converted to UCase.
I understand I can do this for each individual input, but there are a great many.
Thanks.
UCase for all user input
-
- Posts: 1186
- Joined: May 08, 2006 21:58
- Location: Crewe, England
Provided you can work with LINE INPUT, you could write a subroutine:
Code: Select all
sub ucaseinput (question As String, ByRef answer As String)
Dim s1 As String
Print question;
Line Input s1
answer = UCase(s1)
End Sub
Dim s0 As String
While s0<>"QUIT"
ucaseinput("What is your answer? ",s0)
Print s0
Wend
Under Windows you can set caps lock no problem.
And using a different method you can do it under DOS, I don’t know about Linux. The problem with this is that there is nothing to stop the user from resetting caps lock. I think the best solution would be to create an input function that does the conversion and use that for all input.
Code: Select all
#include "windows.bi"
dim ki(1) as INPUT_
if GetKeyState(VK_CAPITAL) = 0 then
ki(0).type = INPUT_KEYBOARD
ki(0).ki.wVk = VK_CAPITAL
ki(1).type = INPUT_KEYBOARD
ki(1).ki.wVk = VK_CAPITAL
ki(1).ki.dwFlags = KEYEVENTF_KEYUP
SendInput( 2, @ki(0), sizeof(INPUT_) )
end if
print GetKeyState(VK_CAPITAL)
sleep
I'll admit that most of this stuff is over my head, and what I ended up doing was converting the inputs to UCase after they were entered. For future programs, I will filter all inputs through an input function that does the conversation as was suggested a couple of times on this thread. Thank you all very much.
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
5 lines is easier to understand... Even though macros are politically incorrect somehow:
Code: Select all
#macro UcaseIn (var)
dim as string var
line input, var
var = ucase(var)
#endmacro
? "What is your name?";
UcaseIn(yourname)
? yourname
sleep