comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » keybaord input
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: keybaord input [message #13017 is a reply to message #12933] Fri, 25 September 1998 00:00 Go to previous messageGo to previous message
Vap User is currently offline  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>
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: colorcoding for emacs
Next Topic: IDL Setup

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 16 01:29:59 PDT 2025

Total time taken to generate the page: 1.04115 seconds