Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
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 ------------------------------------------------------------ ---------------
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>
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