I just found this out a few weeks ago, and have been working on a simple setup script for a few projects so admins can run the script interactively.
# Prompts for y/n
:local prompt "Are you sure? [Y/N]:"
:local options "y,n"
# Array of ascii values and ascii characters
# The ascii values directly correspond to a single ascii character
# asciicharlower and asciicharupper are used for character conversions
:local asciicharlower ("a,b,c,d,e,f,g,h,i,j,k,l," . \
"m,n,o,p,q,r,s,t,u,v,w,x,y,z")
:local asciicharupper ("A,B,C,D,E,F,G,H,I,J,K,L," . \
"M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z")
:local asciichar ("0,1,2,3,4,5,6,7,8,9," . \
"a,b,c,d,e,f,g,h,i,j,k,l," . \
"m,n,o,p,q,r,s,t,u,v,w,x,y,z," . \
"A,B,C,D,E,F,G,H,I,J,K,L," . \
"M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z," . \
".,/")
:local asciival {48;49;50;51;52;53;54;55;56;57; \
97;98;99;100;101;102;103;104;105;106;107;108; \
109;110;111;112;113;114;115;116;117;118;119;120;121;122; \
65;66;67;68;69;70;71;72;73;74;75;76; \
77;78;79;80;81;82;83;84;85;86;87;88;89;90; \
46;47}
:local key
:local findindex
:local validoption
:set key 0
:set validoption 0
# Prompt for input
:put ($prompt)
# Wait until valid option is entered
:while ($validoption = 0) do={
:set key ([:terminal inkey])
# Convert numeric ascii value to ascii character
:set findindex [:find [:toarray $asciival] $key]
:if ([:len $findindex] > 0) do={
:set key [:pick [:toarray $asciichar] $findindex]
}
# If key is uppercase, convert it to lowercase
:set findindex [:find [:toarray $asciicharupper] $key]
:if ([:len $findindex] > 0) do={
:set key [:pick [:toarray $asciicharlower] $findindex]
}
# Check if key is a valid option
:set findindex [:find [:toarray $options] $key]
:if ([:len $findindex] > 0) do={
:set validoption 1
}
# end while validoption = 0
}
# Evaluate input
# At this point, key is converted to lower case
:if ($key = "y") do={
:put ("You confirmed YES")
}
:if ($key = "n") do={
:put ("You chose NO")
}
Basically, this prompts for a single character (y or n). If you type Y or N, it get's converted to lowercase. This way, during evaluation of the input, you only have to evaluate once (y or n).
Hope this helps. You could even set a global variable after input, and pass it to another script for execution.