Shut down application at midnight 
Author Message
 Shut down application at midnight

I have an application that I want to have shut down after midnight.  I have
a timer in the first window.  Other windows are called from this first
window and since it's not the active window, the time event does not fire
unless it becomes the active window.  How can I have the application shut
down, no matter what window is active?


Tue, 13 Jul 2004 03:48:37 GMT  
 Shut down application at midnight
If this is VFP6.0 add you timer to your _screen, which is always there.


Quote:
> I have an application that I want to have shut down after midnight.  I
have
> a timer in the first window.  Other windows are called from this first
> window and since it's not the active window, the time event does not fire
> unless it becomes the active window.  How can I have the application shut
> down, no matter what window is active?



Tue, 13 Jul 2004 04:12:25 GMT  
 Shut down application at midnight
Thanks for the suggestion.  I have a general idea of what you mean.  Could
you give me sample code?  I found how to add the object timer, but how do I
enter the timer event?

I am using VFP7.0


Quote:
> If this is VFP6.0 add you timer to your _screen, which is always there.



> > I have an application that I want to have shut down after midnight.  I
> have
> > a timer in the first window.  Other windows are called from this first
> > window and since it's not the active window, the time event does not
fire
> > unless it becomes the active window.  How can I have the application
shut
> > down, no matter what window is active?



Tue, 13 Jul 2004 08:44:09 GMT  
 Shut down application at midnight
Don,

create your own timerclass (cTimer.prg) derived from Timer

define class cMyTimer as Timer
 Interval= 1000

 procedure Timer
    if Sys(2) < 5 then
          wait window "It's after midnight" nowait
    else
        wait window "Timer fired" nowait
    endif
 endproc

enddefine

Add it when your app starts:

_Screen.NewObject("oTimer", "cMyTimer", "cTimer.prg")

That sould do it.

Cheers
Carsten



Quote:
> Thanks for the suggestion.  I have a general idea of what you mean.  Could
> you give me sample code?  I found how to add the object timer, but how do
I
> enter the timer event?

> I am using VFP7.0



> > If this is VFP6.0 add you timer to your _screen, which is always there.



> > > I have an application that I want to have shut down after midnight.  I
> > have
> > > a timer in the first window.  Other windows are called from this first
> > > window and since it's not the active window, the time event does not
> fire
> > > unless it becomes the active window.  How can I have the application
> shut
> > > down, no matter what window is active?



Tue, 13 Jul 2004 15:44:34 GMT  
 Shut down application at midnight
To add to what Carsten said,

 procedure Timer
    if Sys(2) < 5 then
          wait window "It's after midnight" nowait
    else
        wait window "Timer fired" nowait
    && This is where you put your shutdown procedure
    endif
 endproc


Quote:
> Thanks for the suggestion.  I have a general idea of what you mean.  Could
> you give me sample code?  I found how to add the object timer, but how do
I
> enter the timer event?

> I am using VFP7.0



> > If this is VFP6.0 add you timer to your _screen, which is always there.



> > > I have an application that I want to have shut down after midnight.  I
> > have
> > > a timer in the first window.  Other windows are called from this first
> > > window and since it's not the active window, the time event does not
> fire
> > > unless it becomes the active window.  How can I have the application
> shut
> > > down, no matter what window is active?



Tue, 13 Jul 2004 17:10:58 GMT  
 Shut down application at midnight
Thanx guys.  I haven't done anything with addobject or newobject so it was a
good learning session.


Quote:
> Don,

> create your own timerclass (cTimer.prg) derived from Timer

> define class cMyTimer as Timer
>  Interval= 1000

>  procedure Timer
>     if Sys(2) < 5 then
>           wait window "It's after midnight" nowait
>     else
>         wait window "Timer fired" nowait
>     endif
>  endproc

> enddefine

> Add it when your app starts:

> _Screen.NewObject("oTimer", "cMyTimer", "cTimer.prg")

> That sould do it.

> Cheers
> Carsten



> > Thanks for the suggestion.  I have a general idea of what you mean.
Could
> > you give me sample code?  I found how to add the object timer, but how
do
> I
> > enter the timer event?

> > I am using VFP7.0



> > > If this is VFP6.0 add you timer to your _screen, which is always
there.



> > > > I have an application that I want to have shut down after midnight.
I
> > > have
> > > > a timer in the first window.  Other windows are called from this
first
> > > > window and since it's not the active window, the time event does not
> > fire
> > > > unless it becomes the active window.  How can I have the application
> > shut
> > > > down, no matter what window is active?



Tue, 13 Jul 2004 23:48:40 GMT  
 Shut down application at midnight
Mike,

The else-part will be true for every second after 5 seconds after midnight.
The result might not quite be the expected <g>.

The shutdown-code belongs with the:
   wait window "It's after midnight" nowait - part

I added a limit of 5 seconds, since i had situations where it didn't fire
exactly on the second. Assuming everything works fine, the statement
"if Sys(2) < 5 then " should be "if Sys(2) < 2 then"

Cheers
Carsten



Quote:
> To add to what Carsten said,

>  procedure Timer
>     if Sys(2) < 5 then
>           wait window "It's after midnight" nowait
>     else
>         wait window "Timer fired" nowait
>     && This is where you put your shutdown procedure
>     endif
>  endproc



> > Thanks for the suggestion.  I have a general idea of what you mean.
Could
> > you give me sample code?  I found how to add the object timer, but how
do
> I
> > enter the timer event?

> > I am using VFP7.0



> > > If this is VFP6.0 add you timer to your _screen, which is always
there.



> > > > I have an application that I want to have shut down after midnight.
I
> > > have
> > > > a timer in the first window.  Other windows are called from this
first
> > > > window and since it's not the active window, the time event does not
> > fire
> > > > unless it becomes the active window.  How can I have the application
> > shut
> > > > down, no matter what window is active?



Tue, 13 Jul 2004 19:52:18 GMT  
 Shut down application at midnight
Carsten,

I have a similar timer event at work (to make the lunchtime buzzer sound for
the employees) and I use TIME(). I store the time() every second into a
variable and check with a do case to see if it meets the buzzer criteria and
so far (4 years) I think it missed once. So I personnaly would code for
midnight exactly.


Quote:
> Mike,

> The else-part will be true for every second after 5 seconds after
midnight.
> The result might not quite be the expected <g>.

> The shutdown-code belongs with the:
>    wait window "It's after midnight" nowait - part

> I added a limit of 5 seconds, since i had situations where it didn't fire
> exactly on the second. Assuming everything works fine, the statement
> "if Sys(2) < 5 then " should be "if Sys(2) < 2 then"

> Cheers
> Carsten



> > To add to what Carsten said,

> >  procedure Timer
> >     if Sys(2) < 5 then
> >           wait window "It's after midnight" nowait
> >     else
> >         wait window "Timer fired" nowait
> >     && This is where you put your shutdown procedure
> >     endif
> >  endproc



> > > Thanks for the suggestion.  I have a general idea of what you mean.
> Could
> > > you give me sample code?  I found how to add the object timer, but how
> do
> > I
> > > enter the timer event?

> > > I am using VFP7.0



> > > > If this is VFP6.0 add you timer to your _screen, which is always
> there.



> > > > > I have an application that I want to have shut down after
midnight.
> I
> > > > have
> > > > > a timer in the first window.  Other windows are called from this
> first
> > > > > window and since it's not the active window, the time event does
not
> > > fire
> > > > > unless it becomes the active window.  How can I have the
application
> > > shut
> > > > > down, no matter what window is active?



Fri, 16 Jul 2004 18:18:47 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Closing application when Windows shut down

2. Shut down application if no activity

3. How do you shut down another running application?

4. shut down from vfp

5. Fatal Exception Error and Shut Down

6. Shutting down an external program

7. Shut down Windows 95 programmatically

8. VFP5 shuts down machine

9. Shutting down Windows from foxpro

10. Shut Down Windows

11. Shutting down Win95 from VFP 3.0b

12. Executable keeps shutting down

 

 
Powered by phpBB® Forum Software