Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Newbie question for today

From: carl:cybercraft at: 24-Dec-2003 22:38

On 07-Oct-03, Kai Peters wrote:
> I am trying to write an app that monitors a given set of directories > on the local drive at 5 min. intervals and then transfers any file > it may find in one of these dirs to a ftp server, so it needs to > basically loop forever. > I want to have a Start/Stop toggle to initate or cancel this > operation. > How do I test for a 'cancel event' in my forever loop. Does someone > have a little sample snippet that demonstrates Rebol's abilities for > this purpose?
Hi Kai, If you can use View, you could use it's window event handling. Here's a little example... rebol [] view layout [ across label "Event Time" event-time: info rate 5:00 feel [ engage: func [face action event][ if event/type = 'time [ ; Event acted on here... event-time/text: to-string now/time show event-time ] ] ] return label "Rate Secs:" field "300" [ event-time/rate: to-time to-integer face/text ] return button "Stop" [ event-time/rate: none event-time/text: "Stopped" show event-time ] ] To see that working, enter 5 (for 5 seconds) in the "Rate Secs:" field. An event should then happen every five seconds, which you can stop with the Stop button and re-start again by entering another number in the seconds' field. See http://www.rebol.com/how-to/feel.html for more on View's event handling. I've not done anything similar in Core though, so others would be better qualified to answer if it is a Core script you need. -- Carl Read