Hamster-Scripts: Functions (built-in)

Scheduler

AtClear

Clears all scheduler entries.

Returns: 0

# see example under AtAdd

AtAdd( <subname>, <from>, <til>, <wdays>, <repeat>, <immediate> )

...
AtAdd( <subname>, <from> )

Adds a new scheduler entry.

<subname> gives the name of a user-defined "sub", which is startet when the entry is triggered by "AtExecute".

<from> and <til> contain the time-period, in which the entry is triggered (default for <til> is <from>; format for both is "HH.MM").

<wdays> is a string which contains a marker for each day of the week for which the entry is valid ("1"=valid; first char=Monday, ..., seventh char=Sunday; default="1111111").

If <rep> contains a value greater than 0, the entry is triggered every <repeat> minutes.

If a script is started at a time, for which one of the entries is valid, <subname> is called immediately by default. If <immediate> is set to 0 (false), it is assumed that this event already happend at the time, the entry was added.

Returns: Index of new entry.

AtClear
AtAdd( getmails, "00:00", "06:00", "1111100", 60, true )
AtAdd( getmails, "06:00", "18:00", "1111100", 15, true )
AtAdd( getmails, "18:00", "24:00", "1111100", 60, true )
AtAdd( getmails, "12:00", "",      "0000011" )
AtAdd( getnews,  "03:15" )
AtAdd( getnews,  "18:45" )
AtExecute
quit

sub getmails
   # ...
endsub

sub getnews
   # ...
endsub

AtExecute( <timeout> )

AtExecute

Waits until one of the scheduler-entries added by "AtAdd" is triggered, executes its accompanying sub-function and if this function returns 0, it continues to wait for the next entry to come.

<timeout> gives the maximum time in milliseconds (1/1000 seconds), AtExecute should wait for the next entry.

Returns: -1=timeout, >0: return-value of last executed sub.

# see example under AtAdd

[Hamster Ys Documentation]