From: Gajo de Bruin on
Hi,

I'm trying to create a program that runs every hour or
sooner when a key is pressed.
So far I've been able to create the 1 hour loop with info
on the screen that says when the program will start again:

tic
a=toc;
while a<ReRunDelay
clc
display(['The program will restart in ' num2str
(floor(ReRunDelay-a)) ' seconds.'])
pause(1)
a=toc;
end

In my Qbasic times ( I know, a long time ago) I used the
INKEY$ to check for a keypress and break the loop:


DO

"code"

A$ = INKEY$ 'Get Key
IF A$ = CHR$(27) THEN END '<---ESC button

LOOP

Any idea's on how I can do this in Matlab?

Kind regards,
Gajo

From: Walter Roberson on
In article <fvrl3b$sr9$1(a)fred.mathworks.com>,
Gajo de Bruin <ikke(a)nowhere.eu> wrote:

>I'm trying to create a program that runs every hour or
>sooner when a key is pressed.

If you have a figure, you can use the WindowKeyPressFcn callback.

If you do not have a figure then you could use input() along
with a timer object that threw an error() when the time expired.
But input() needs a return, not just pressing a key.

If you need single key I/O then Matlab does not supply it.
If you happen to be using a PC then I believe that there is a Windows
specific Matlab File Exchange (FEX) contribution for this purpose.
--
"There is nothing so bad but it can masquerade as moral."
-- Walter Lippmann