keybaord input [message #12933] |
Thu, 24 September 1998 00:00  |
Rob MacLeod
Messages: 1 Registered: September 1998
|
Junior Member |
|
|
Folks,
Simple, beginners questions, but I want to have some very basic control
over a program via the keyboard. For example, viewing a set of images and
use "n" for next image "p" for previous, etc. Widgets are overkill and
more time than I am willing to commit. But instead a command that waits
for keyboard input, returns the value entered, which I then process inside
the program. Braindead stuff in any other language I have used but I
cannot seem to find it in IDL (maybe it's me who is braindead on this one
(-: ).
If this matters, I need this for the Mac implementation of IDL 5
Thanks,
Rob
--
------------------------------------------------------------ --------------
Rob MacLeod, Ph.D.
Nora Eccles Harrison Cardiovascular Research and Training Institute (CVRTI)
Building 500, University of Utah
Salt Lake City, Utah 84112 ____ __o
Internet: macleod@cvrti.utah.edu ____ -\<,
Phonemail: (801)581-8183 ....0/ 0
Fax: (801)581-3128
------------------------------------------------------------ ---------------
|
|
|
Re: keybaord input [message #13017 is a reply to message #12933] |
Fri, 25 September 1998 00:00  |
Vap User
Messages: 31 Registered: April 1998
|
Member |
|
|
Rob MacLeod <macleod@orthus.cvrti.utah.edu> writes:
>
> Folks,
>
> Simple, beginners questions, but I want to have some very basic control
> over a program via the keyboard. For example, viewing a set of images and
> use "n" for next image "p" for previous, etc. Widgets are overkill and
> more time than I am willing to commit. But instead a command that waits
> for keyboard input, returns the value entered, which I then process inside
> the program. Braindead stuff in any other language I have used but I
> cannot seem to find it in IDL (maybe it's me who is braindead on this one
> (-: ).
>
You can use either read,'prompt', variable or ret=get_kbrd(1) inside
a repeat... until loop. Using Read,... will allow more than one
character input from the user, get_kbrd(1) only reads one character
for each call.
Something like this would work.
usr_input=''
repeat begin
; either do this
read,"What do you want to do (P=prev/N=next/Q=quit)? ",usr_input
ret=strupcase( strmid( strtrim( usr_input,2),0,1) )
; or this
print,' What do you want to do (P=prev/N=next/Q=quit)? '
ret=strupcase(get_kbrd(1))
; but using get_kbrd() I found that I had to process the 'return'
; key, i.e.
junk=get_kbrd(0)
; despite the help page claiming that you can't process return
; events this way. Go figure!
case ret of
'P': begin
; go backwards
end
'N' : begin
; go forwards
end
'Q' :
else: begin
message,'Sorry, no savvy! Try again',/cont
end
endcase
endrep until ret eq 'Q'
return
> If this matters, I need this for the Mac implementation of IDL 5
>
Hope it doesn't matter.
> Thanks,
>
> Rob
> --
> ------------------------------------------------------------ --------------
> Rob MacLeod, Ph.D.
> Nora Eccles Harrison Cardiovascular Research and Training Institute (CVRTI)
> Building 500, University of Utah
> Salt Lake City, Utah 84112 ____ __o
> Internet: macleod@cvrti.utah.edu ____ -\<,
> Phonemail: (801)581-8183 ....0/ 0
> Fax: (801)581-3128
> ------------------------------------------------------------ ---------------
--
I don't speak for JPL, it doesn't speak for me.
Well, not all the time, at least.
William Daffer <vapuser@haifung.jpl.nasa.gov>
|
|
|
Re: keybaord input [message #13023 is a reply to message #12933] |
Fri, 25 September 1998 00:00  |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
In article <u6bto5ibv4.fsf@orthus.cvrti.utah.edu> Rob MacLeod
<macleod@orthus.cvrti.utah.edu> writes:
> Simple, beginners questions, but I want to have some very basic control
> over a program via the keyboard. For example, viewing a set of images and
> use "n" for next image "p" for previous, etc. Widgets are overkill and
> more time than I am willing to commit. But instead a command that waits
> for keyboard input, returns the value entered, which I then process inside
> the program. Braindead stuff in any other language I have used but I
> cannot seem to find it in IDL (maybe it's me who is braindead on this one
> (-: ).
See the online help for GET_KBRD().
Regards,
Stein Vidar
|
|
|