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

[REBOL] Re: A question in time saves... Clouds???

From: carl:cybercraft at: 5-Jun-2001 21:57

Hi Jim, I see while I've been writing this that Graham's given you a function to wait on a time, but perhaps some of the following will still be of use to you... On 05-Jun-01, Jimbo wrote:
> Hi again, > It's the Happy Hippy back with another question. > Please forgive my repeated intrusions. O :-)
Heh - you're the silver-lining, man. (:
> I'm still working on the same automated cloud catcher. > I've expanded it (cut & paste) to grab all nine sections > needed for the cloud cover of the /entire/ earth which > was my original goal. Everything is working OK except > that the time required to do the nine grabs varries > from set to set. So I got looking into it and it apears > as if I can use the "WAIT" command with a block of times > in brackets. I wonder... Is this true? If so what would > it be formatted like? I feel pretty silly here, not even > knowing basic REBOL syntax :-/ > Ummm... > wait [time1, time2 time3, > time4, time5, time6] > ???
Apart from the commas (not needed in REBOL) the syntax is fine, except it still won't work. (How you use a block with 'wait I'm not sure - can't find much in the manuals on 'wait...) But read on...
> and what does a time string look like? I could find wait 100 which > is no. of seconds and I was shown wait 10:20:30, HH:MM:SS. How about > a specific time like 11:32 PM ?
First, a quick way to see a REBOL date+time is to just type "now" at the Console...
>> now
== 5-Jun-2001/19:57:11+12:00 And if you examine the 'now word it shows how you get at the various bits of it...
>> ? now
USAGE: NOW /year /month /day /time /zone /date /weekday /precise DESCRIPTION: Returns the current local date and time. NOW is a native value. REFINEMENTS: /year -- Returns the year only. /month -- Returns the month only. /day -- Returns the day of the month only. /time -- Returns the time only. /zone -- Returns the time zone offset from GMT only. /date -- Returns date only. /weekday -- Returns day of the week as integer (Monday is day 1). /precise -- Use nanosecond precision So, to see a time value enter...
>> now/time
== 20:05:49 As I see it, there's two ways to approach your problem. One would be to write a bit of code to wait on times in a block, (as you'd hoped 'wait could do and perhaps it can:), or use REBOL's 'modified? word to check the URLs every ten minutes or so to see if the JPGs have changed since you last downloaded them...
>> ? modified?
USAGE: MODIFIED? target DESCRIPTION: Returns the last modified date of a file or URL. MODIFIED? is a function value. ARGUMENTS: target -- (Type: file url) (SPECIAL ATTRIBUTES) catch Something like this might work (code not checked)... old-time: now forever [ file-time: modified? url-name if file-time <> old-time [ get-clouds-routine old-time: file-time ] wait 00:10:00 ] That depends on you being able to get the file's modified time though - with some files on the Net you don't seem to be able to. As to using a block of times, something like this could perhaps be used (I've tested this - Esc to Exit.)... times: [00:00:05 00:00:04 00:00:03 00:00:02 00:00:01] forever [ ; Main code here wait first times print first times times: next times if empty? times [times: head times] ] That doesn't wait for a certain time of day though, (others will have to tell you how to do that), so you might have to always start your script on the hour - till you work out how to create the 'times block based on the time you run your script. (: Have fun. -- Carl Read [carl--cybercraft--co--nz]