/*******************************************************************
* ARexx Script: OnTime_UpdateFullMoon.rexx                         *
* Version.....: 1.01 (31.08.96)                                    *
* ---------------------------------------------------------------- *
* This script looks for an Event with a name 'Do:#?Full moon#?'    *
* It asumes this is a Full Moon Event and will update its begin    *
* date to the next occurance of a full moon after the current      *
* system date.                                                     *
*******************************************************************/

options results

/* Set the Event filter to display all 'Do:' Events */
'filterstring event mn=Do:#?'
'filter event 1'

/* Do a search for the Full moon Event */
'active event noactive'
'search event field 1 #?Full#?moon#?'

/* Get the number of the active entry */
'getactive event'
active = result

/* If there is no active entry then we'll assume it doesn't exist
   and we'll just exit */
if (active = 0) then
	exit(0)

/* Get the original begin date of the Event */
'getfield event entry 'active' 3'
old_date = result

/* Find the next occurance of the full moon from the current date */
'dateinfo moonphase 3'
new_date = result

/* If the original date and the new date are not the same then we'll
   adjust the Event's date to match */
if (old_date ~= new_date) then
	'setfield event entry 'active' 3 'new_date

/* Redraw opened calendars */
update

/* End */
