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

Newbie question for today

 [1/4] from: kpeters:mvinc at: 6-Oct-2003 16:58


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? Again, thanks a lot in advance! Kai

 [2/4] 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
<<quoted lines omitted: 5>>
> 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

 [3/4] from: g::santilli::tiscalinet::it at: 7-Oct-2003 9:57


Hi Kai, On Tuesday, October 7, 2003, 1:58:02 AM, you wrote: KP> I am trying to write an app that monitors a given set of directories on the KP> local drive at 5 min. intervals and then transfers any file it may find in KP> one of these dirs to a ftp server, so it needs to basically loop forever. KP> I want to have a Start/Stop toggle to initate or cancel this operation. KP> How do I test for a 'cancel event' in my forever loop. Does someone have a KP> little sample snippet that demonstrates Rebol's abilities for this purpose? view/new layout [ Button "Stop" [done: yes unview/all] ] done: no check-my-dir: does [print "Checking..."] until [ check-my-dir wait 5 ; just 5 seconds to test it done ] (You could also just quit when the user presses stop, but I assume you want to do something else after the loop.) I'll leave adding the start button as an exercise. ;-) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [4/4] from: antonr:iinet:au at: 7-Oct-2003 12:19


How about this: do-scan?: yes view/new lay: layout [ button "scan on" [do-scan?: yes] button "scan off" [do-scan?: no] ] ;;; <- (insert feel code, below) forever [wait [0:0:3] print now if do-scan? [print "do scan"]] 7-Oct-2003/12:12:13+10:00 do scan 7-Oct-2003/12:12:16+10:00 do scan ;;;; <--- here I pressed "scan off" button 7-Oct-2003/12:12:19+10:00 7-Oct-2003/12:12:22+10:00 7-Oct-2003/12:12:25+10:00 ... You would need to catch the close event of the window and turn the scan off or break the forever loop anyway. lay/feel: make lay/feel [ detect: func [face event][ if event/type = 'close [ do-scan?: no ] event ; return the event so it can be processed ] ] Anton.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted