A question in time saves... Clouds???
[1/7] from: jimbo::sc::starcat::ne::jp at: 5-Jun-2001 14:56
Hi again,
It's the Happy Hippy back with another question.
Please forgive my repeated intrusions. O :-)
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]
???
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 ?
--
Thanks for all your help so far and in advance for this.
Jim
HH
[2/7] from: gchiu:compkarori at: 5-Jun-2001 20:04
> 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 ?
I wrote this a couple of years ago:
wait-till: func [ o'clock ] [
either now/time < o'clock [
wait ( o'clock - now/time )
][
wait ( 24:00 - now/time + o'clock )
]
]
eg:
wait-till 2:00 ; wait till 2 AM.
--
Graham Chiu
[3/7] 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
<<quoted lines omitted: 10>>
> 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]
[4/7] from: jimbo:sc:starcat:ne:jp at: 5-Jun-2001 19:19
Ah! yes.. thankyou, I see it.
I kinda remember that now too.
00:00:00 = HH:MM:SS = Timer
00:00 = HH:MM = Time of day
0 = S = Timer in seconds
Thanks for that! Now you wouldn't happen to know how to
put many "Time of day" strings in a data block would you?
I need the wait command to hold execution until specific
times of day. Like a chime every 30 minutes at
exactly 1:00, 1:30, 2:00, 2:30, etc.
Can I just do:
wait [12:00, 12:30, 13:00, 13:30, 14:00, 14:30,
15:00, 15:30, 16:00, 16:30, 17:00, 17:30,
18:00, 18:30, 19:00, 19:30, 20:00, 20:30,
21:00, 21:30, 22:00, 23:30, 00:00, 00:30,
01:00]
in a loop?
Graham Chiu wrote:
[5/7] from: jimbo:sc:starcat:ne:jp at: 5-Jun-2001 19:51
Carl Read wrote:
> Hi Jim,
> I see while I've been writing this that Graham's given you a function
<<quoted lines omitted: 5>>
>> Please forgive my repeated intrusions. O :-)
> Heh - you're the silver-lining, man. (:
Hey, Cool! Thanks that makes me feel good. Thanks!
>> I'm still working on the same automated cloud catcher.
>> I've expanded it (cut & paste) to grab all nine sections
<<quoted lines omitted: 11>>
>> ???
> Apart from the commas (not needed in REBOL) the syntax is fine,...
Ah! Ha! Got it... ummm.. Maybe.. O :-)
REBOL []
if not exists? %pictures/ [
make-dir %pictures/
]
forever [
page: read
http://wwwghcc.msfc.nasa.gov/cgi-bin/get-goes?satellite=long URL !!!
parse page [thru "SRC=^"/" copy pic-path to "^" WIDTH" to end]
write/binary join %pictures/ to-file last parse pic-path "/" read/binary
join to-url http://wwwghcc.msfc.nasa.gov/ pic-path
wait [12:00 12:30 13:00 13:30 14:00 14:30
15:00 15:30 16:00 16:30 17:00 17:30
18:00 18:30 19:00 19:30 20:00 20:30
21:00 21:30 22:00 23:30 00:00 00:30
01:00]
]
Oh no wait... I forget! Can ya put a data block inside a function
command like "forever[]" ???
> 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...
Mmmm Ya... Me too. I looked and found where it said you could do it
but there was no example code so I flew back here. I've read some more
while waiting but I think that has actually confussed me even more; a task
easily accomplished!
X^/
> 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...
I don't know (of coarse! ;-) but I think that wouldn't work in my case
because NASA is generateing the map names randomly per request but
the actual map data is only updated every half hour at a quarter past
and a quarter till.
> 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.
Hehehe ... Yup! this is something I will run once for 2 or 3 days
straight
and then never look at again.
Well I'm alot closer thanks to you and Graham Chu!!!
--
Shisyo dono, domo arigato gozaimasu!!!
James Dean Prentice III
Just some old Hippy
Hang'en out in Japan
[6/7] from: carl:cybercraft at: 5-Jun-2001 22:56
On 05-Jun-01, Tesselator wrote:
> Ah! yes.. thankyou, I see it.
> I kinda remember that now too.
<<quoted lines omitted: 13>>
> 01:00]
> in a loop?
Ahah - I think the email I've just sent may be of use. (: Instead of
using wait in the example I gave, use Graham's wait-till function
instead. Something like this...
times: [12:00 12:30 13:00 13:30] ; etc...
forever [
; Main code here
wait-till first times
print first times
times: next times
if empty? times [times: head times]
]
The 'first gets the first value in the block, 'next moves the block's
index along, and when the block seems empty, (it's not really - it's
just that its ('times's, actually) index is pointing at its end), the
'head word returns the block back to its original state.
> Graham Chiu wrote:
>>> and what does a time string look like? I could find
<<quoted lines omitted: 21>>
>> --
>> Graham Chiu
--
Carl Read
[carl--cybercraft--co--nz]
[7/7] from: cyphre:volny:cz at: 5-Jun-2001 14:00
Hello,
Maybe this would help you:
times: [13:59 14:00]
action: [print "bang!"]
wait-loop: does [
dispatch [1 [
if equal? now/time first times [
times: next times
if tail? times [times: head times]
do action
]
wait-loop
]]]
wait-loop
or another version with unique actions for each event:
times: [12:54 [print "bing!"] 12:58 [print "bang!"] 13:00 [print "bong!"]]
wait-loop: does [
dispatch [1 [
if equal? now/time first times [
do next times
times: skip times 2
if tail? times [times: head times]
]
wait-loop
]]]
wait-loop
have fun,
Cyphre
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted