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

Home » Public Forums » archive » keypressed pauses program - how to do that?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
keypressed pauses program - how to do that? [message #3067] Sat, 05 November 1994 09:05 Go to next message
frank is currently offline  frank
Messages: 15
Registered: August 1993
Junior Member
Hi all,
basically what I have is a program like this:

FOR loop=0,1000 DO BEGIN
TVSCL, image(loop)
WAIT, 2
ENDFOR

because the images aren't very big it's quite fast.
to make it slower I inserted a 'WAIT, 2' after the TVSCL line.
But that's not what I want to do. It would be much nicer to have something
like a key-controled slide-show, where e.g. <space> toggles pause/slide mode
and e.g <return> (in pause mode) advances the images manually.
I know there's some function for keyboard-stuff in IDL, but I don't know it's
name, and I have no idea how to implement it, that it works the waz I described
above. Maybe somebody wrote something similar an can help me out now.

thanx in advance

--
Frank Hoffsuemmer _ /| ACK E-Mail:frank@chaos.uni-frankfurt.de
Institut fuer Theor. Physik \'o_O' /
Robert-Mayer-Str. 8 =( )= Office: Phone (49) 69 / 798-3359
D-60054 Frankfurt am Main U Fax (49) 69 / 798-8354
Germany
Re: keypressed pauses program - how to do that? [message #3149 is a reply to message #3067] Tue, 08 November 1994 07:01 Go to previous messageGo to next message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
frank@chaos.uni-frankfurt.dbp.de (Frank Hoffsuemmer) writes:

> Hi all,
> basically what I have is a program like this:

> FOR loop=0,1000 DO BEGIN
> TVSCL, image(loop)
> WAIT, 2
> ENDFOR

> because the images aren't very big it's quite fast.
> to make it slower I inserted a 'WAIT, 2' after the TVSCL line.
> But that's not what I want to do. It would be much nicer to have something
> like a key-controled slide-show, where e.g. <space> toggles pause/slide mode
> and e.g <return> (in pause mode) advances the images manually.
> I know there's some function for keyboard-stuff in IDL, but I don't know it's
> name, and I have no idea how to implement it, that it works the waz I described
> above. Maybe somebody wrote something similar an can help me out now.

What you want to use is GET_KBRD. This gets a single character from the input
buffer of the keyboard. If you say

Char = GET_KBRD(1)

then the program waits until the user presses one of the keys. If you say

Char = GET_KBRD(0)

then the program reads from the input buffer without waiting, or returns a null
if nothing's there.

One needs to be aware of two things:

1. GET_KBRD only returns a single character. If the key pressed generates an
escape sequence, then repeated calls to GET_KBRD are needed to read in the
entire sequence.

2. The last time I checked, in IDL for Windows, the non-printing characters
such as carriage-return or line-feed, all are read in as the null character.
This isn't true for other platforms.

Here's an example of a program that uses GET_KBRD.

Bill Thompson


============================================================ ===================
PRO PAUSE,SWITCH
;+
; NAME:
; PAUSE
; PURPOSE:
; Pauses until a key is pressed at the keyboard.
; CATEGORY:
; CALLING SEQUENCE:
; PAUSE [, SWITCH ]
; OPTIONAL INPUT PARAMETERS:
; SWITCH - If nonzero and !D.NAME is 'PS', then no action is taken.
; The default value for SWITCH is 0; i.e. PAUSE will take
; effect no matter what plotting device is in use.
; OUTPUTS:
; None.
; OPTIONAL OUTPUT PARAMETERS:
; None.
; COMMON BLOCKS:
; None.
; SIDE EFFECTS:
; If the character entered is "Q", then the PAUSE procedure executes a
; RETALL command.
; RESTRICTIONS:
; The variable SWITCH must not be an array, or of type string.
; PROCEDURE:
; The GET_KBRD function is used.
; MODIFICATION HISTORY:
; William Thompson Applied Research Corporation
; September, 1987 8201 Corporate Drive
; Landover, MD 20785
;-
;
ON_ERROR,2
;
; If SWITCH is passed and is nonzero, then check to see if PAUSE will have any
; effect.
;
IF N_PARAMS(0) EQ 0 THEN SWITCH = 0
IF (SWITCH NE 0) AND (!D.NAME EQ 'PS') THEN RETURN
;
; Force the plot buffer to empty so that the entire current plot is visible.
;
EMPTY
;
; Loop until a character is entered at the keyboard. If the character "Q" is
; pressed, then return to the main level.
;
TEST_CHAR = GET_KBRD(1)
IF STRUPCASE(TEST_CHAR) EQ "Q" THEN RETALL
;
RETURN
END
Re: keypressed pauses program - how to do that? [message #3154 is a reply to message #3067] Sat, 26 November 1994 00:07 Go to previous message
polysci_info is currently offline  polysci_info
Messages: 3
Registered: September 1994
Junior Member
In article <39ge03$1do7@jurpool0.rz.uni-frankfurt.de>, frank@chaos.uni-frankfurt.dbp.de (Frank Hoffsuemmer) writes:

: ...It would be much nicer to have something
: like a key-controled slide-show, where e.g. <space> toggles pause/slide mode
: and e.g <return> (in pause mode) advances the images manually.
: I know there's some function for keyboard-stuff in IDL, but I don't know it's
: name, and I have no idea how to implement it, that it works the waz I described
: above. Maybe somebody wrote something similar an can help me out now.

Here's something I hacked together for a customer who wanted a pause until
one of three events occurred--a mouse button click, a keyboard press, or
a time out. Maybe you can change the loop logic and use it. Note that this
is PV~WAVE, so I don't know how IDL time/date functions apply.

----8<--------8<--------8<----CUT HERE----8<--------8<--------8<----
pro user_continue

minute=1d0/(24*60)

t=today()
start=t.julian

repeat begin

cursor,x,y,/nowait
button=!err
button_press=button ne 0

key=byte(get_kbrd(0))
key_press=key(0) ne 0

t=today()
time_out=t.julian ge start+minute/2
endrep until button_press or key_press or time_out
end
----8<--------8<--------8<----CUT HERE----8<--------8<--------8<----

Good luck,

Mark Thomas
Technical Director

Polygrafix
Agents for PV~WAVE and other VNI products in Sub-Saharan Africa

Post: PO Box 85385 Email: PolySci_Info@is.co.za
Emmarentia 2029 Tel: +27 11 486-0050
South Africa FAX: +27 11 486-2757
Re: keypressed pauses program - how to do that? [message #3180 is a reply to message #3067] Mon, 21 November 1994 09:06 Go to previous message
dutch is currently offline  dutch
Messages: 8
Registered: June 1992
Junior Member
In article <39ge03$1do7@jurpool0.rz.uni-frankfurt.de>, frank@chaos.uni-frankfurt.dbp.de (Frank Hoffsuemmer) writes:
Hi all,
basically what I have is a program like this:

FOR loop=0,1000 DO BEGIN
TVSCL, image(loop)
WAIT, 2
ENDFOR

because the images aren't very big it's quite fast.
to make it slower I inserted a 'WAIT, 2' after the TVSCL line.
But that's not what I want to do. It would be much nicer to have something
like a key-controled slide-show, where e.g. <space> toggles pause/slide mode
and e.g <return> (in pause mode) advances the images manually.
I know there's some function for keyboard-stuff in IDL, but I don't know it's
name, and I have no idea how to implement it, that it works the waz I described
above. Maybe somebody wrote something similar an can help me out now.
--------------------------------------------------------
Maybe you should check out the XANIMATE widget-based routine which allows you
to produce an animation from a series of images, with mouse-control over the display rate, ability to pause on an image, etc. This may be preferable to
reading from the keyboard. (PS: the procedure 'read' can also be used to read from the keyboard).

-- Michael
###########################################################
# Dr. Michael Dutch email: dutch@eltcv1.epfl.ch #
# Centre de Recherches en Physique des Plasmas #
# Ecole Polytechnique Federale de Lausanne #
# 21 Ave des Bains Aussie.Abroad #
# CH-1007 Lausanne, SWITZERLAND ,--_|\ #
#---------------------------------------- / \ #
# << This space available for rent >> \_.-*._/ #
# Bill Posters is innocent! v #
###########################################################
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Floating Point Bug on Intel Pentium CPUs
Next Topic: Q: square plots in IDL

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

Current Time: Wed Oct 08 15:34:03 PDT 2025

Total time taken to generate the page: 0.00449 seconds