home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
library
/
asic
/
ascsu215
/
getkey.asi
< prev
next >
Wrap
Text File
|
1991-11-12
|
7KB
|
356 lines
start:
rem GETKEY.COM
rem This command gets a key from the keyboard, Aa through Zz and 1 through 9,
rem and returns an Errorlevel of 1 through 36. A or a returns 1, 9 returns 36.
rem The function keys return 37-46, and Esc returns an Errorlevel of 0.
rem Alternatively, you can just display a message, with the /m parameter.
rem Operation will suspend until any key is pressed. With this parameter,
rem GETKEY works just like DOS's PAUSE command, except that you can display
rem the message of your choice, rather than be limited by "Strike a key" etc.
rem A third option is to get only a y or n response to a question, or the Esc
rem key (intended to be used for quitting the program, but you can probably
rem think of some other, more creative uses), with the /q (question)
rem parameter. y or n can be either upper or lower case.
rem First we get keyboard input, using command$, and place a space after it for
rem pretty printing.
a$=command$
a$=a$+ " "
rem Now we check for the "message" parameter.
d$=mid$(a$,1,3)
if d$=" /m" then message:
if d$=" /M" then message:
rem Here is the parameter for getting a y or n response.
if d$=" /q" then getyn:
if d$=" /Q" then getyn:
rem Here is the parameter for sending errorcodes to the system.
if d$=" /e" then geterror:
if d$=" /E" then geterror:
rem Here is the parameter for getting help.
if d$=" /?" then help:
rem If no command line message, the user probably needs help.
if a$=" "then checkhlp:
checkhlp:
print "Do you need help? (y/n)";
wrongkey:
wait4:
wait$=inkey$
if wait$="" then wait4:
if wait$="y" then help:
if wait$="Y" then help:
if wait$="n" then sorry:
if wait$="N" then sorry:
goto wrongkey:
sorry:
print wait$
cls
print "Sorry, this batch file command requires a command line message in order"
print "to do any meaningful work. To get help, type GETKEY /?."
goto finish:
geterror:
rem If /e parameter, we print the message and wait for a key.
d$=mid$(a$,5,79)
print d$;
wait:
b$=inkey$
if b$="" then wait:
rem if function keys are pressed then goto the extended key reading module.
if extended=1 then readext:
c$=chr$(27)
if b$=c$ then exit0:
if b$="a" then exit1:
if b$="A" then exit1:
if b$="b" then exit2:
if b$="B" then exit2:
if b$="c" then exit3:
if b$="C" then exit3:
if b$="d" then exit4:
if b$="D" then exit4:
if b$="e" then exit5:
if b$="E" then exit5:
if b$="f" then exit6:
if b$="F" then exit6:
if b$="g" then exit7:
if b$="G" then exit7:
if b$="h" then exit8:
if b$="H" then exit8:
if b$="i" then exit9:
if b$="I" then exit9:
if b$="j" then exit10:
if b$="J" then exit10:
if b$="k" then exit11:
if b$="K" then exit11:
if b$="l" then exit12:
if b$="L" then exit12:
if b$="m" then exit13:
if b$="M" then exit13:
if b$="n" then exit14:
if b$="N" then exit14:
if b$="o" then exit15:
if b$="O" then exit15:
if b$="p" then exit16:
if b$="P" then exit16:
if b$="q" then exit17:
if b$="Q" then exit17:
if b$="r" then exit18:
if b$="R" then exit18:
if b$="s" then exit19:
if b$="S" then exit19:
if b$="t" then exit20:
if b$="T" then exit20:
if b$="u" then exit21:
if b$="U" then exit21:
if b$="v" then exit22:
if b$="V" then exit22:
if b$="w" then exit23:
if b$="W" then exit23:
if b$="x" then exit24:
if b$="X" then exit24:
if b$="y" then exit25:
if b$="Y" then exit25:
if b$="z" then exit26:
if b$="Z" then exit26:
if b$="0" then exit27:
if b$="1" then exit28:
if b$="2" then exit29:
if b$="3" then exit30:
if b$="4" then exit31:
if b$="5" then exit32:
if b$="6" then exit33:
if b$="7" then exit34:
if b$="8" then exit35:
if b$="9" then exit36:
goto wait:
readext:
print
if b$=";" then exit37:
if b$="<" then exit38:
if b$="=" then exit39:
if b$=">" then exit40:
if b$="?" then exit41:
if b$="@" then exit42:
if b$="A" then exit43:
if b$="B" then exit44:
if b$="C" then exit45:
if b$="D" then exit46:
goto wait:
exit0:
print
end
exit1:
print b$
end 1
exit2:
print b$
end 2
exit3:
print b$
end 3
exit4:
print b$
end 4
exit5:
print b$
end 5
exit6:
print b$
end 6
exit7:
print b$
end 7
exit8:
print b$
end 8
exit9:
print b$
end 9
exit10:
print b$
end 10
exit11:
print b$
end 11
exit12:
print b$
end 12
exit13:
print b$
end 13
exit14:
print b$
end 14
exit15:
print b$
end 15
exit16:
print b$
end 16
exit17:
print b$
end 17
exit18:
print b$
end 18
exit19:
print b$
end 19
exit20:
print b$
end 20
exit21:
print b$
end 21
exit22:
print b$
end 22
exit23:
print b$
end 23
exit24:
print b$
end 24
exit25:
print b$
end 25
exit26:
print b$
end 26
exit27:
print b$
end 27
exit28:
print b$
end 28
exit29:
print b$
end 29
exit30:
print b$
end 30
exit31:
print b$
end 31
exit32:
print b$
end 32
exit33:
print b$
end 33
exit34:
print b$
end 34
exit35:
print b$
end 35
exit36:
print b$
end 36
exit37:
end 37
exit38:
end 38
exit39:
end 39
exit40:
end 40
exit41:
end 41
exit42:
end 42
exit43:
end 43
exit44:
end 44
exit45:
end 45
exit46:
end 46
rem Here is the routine to just pause while printing the message of your choice.
message:
e$=mid$(a$,5,79)
print e$;
wait2:
a$=inkey$
if a$="" then wait2:
goto finish:
rem Get only y(Y) or n(N) response if /q (question) parameter selected.
getyn:
ac$=mid$(a$,5,79)
ad$=ac$+"(y/n) "
print ad$;
wait3:
a$=inkey$
if a$="" then wait3:
if a$="y" then exit2b:
if a$="Y" then exit2b:
if a$="n" then exit1b:
if a$="N" then exit1b:
b$=chr$(27)
if a$=b$ then exit0:
goto wait3:
exit2b:
print a$
end 2
exit1b:
print a$
end 1
help:
print wait$
cls
print "To print a message and get a response from a-z, A-Z, 0-9, the function"
print "keys, or the Esc key, the syntax is GETKEY /e Message. Message can be"
print "up to 79 characters (including spaces) long. An errorlevel is returned"
print "depending on the key pressed. A-Z return a code of 0-26. Either"
print "upper or lower case can be used. 0-9 return a code of 27-36. The"
print "function keys return 37-46. Esc returns an errorlevel of 0."
print
print
print "To just print a message, pause, and wait for any key to be pressed,"
print "the syntax is GETKEY /m Message. Message can be up to 79 characters"
print "long, including spaces."
print
print
print "To get a y or n response, or the Esc key, translated into errorlevel"
print "2, 1, or 0, the syntax is GETKEY /q Yes or no question."
print
print
print "To get this help screen, the syntax is GETKEY /?."
print
print
print "If this screen hasn't helped, and you still can't get the program going,"
print "please consult GETKEY.DOC, or call me between 9AM and 9PM EST. Ask for"
print "Matt. (802)223-2553"
finish:
end