Here's the program to fire the first weekday of each month.
## event_test.tg
# This script demonstrates advanced pattern matching using -match and
# the event directives: -setevent, -clearevent, and -checkevent.
# This script will perform its work only the first weekday of each month.
# What is interesting is that -match doesn’t know about only doing things
# once, therefore we use events to signal when we have run once,
# then reset the event once we no longer match.
##
## event_cleanup
# simple one-time job to reset event on startup
{
-name event_cleanup
-start
-action -clearevent been_here
-stop
}
## event_test
# main worker job to test the current date/time each day at 8 AM
# we are testing to see if the current date is the first weekday in a month
# if match TRUE, follow the true branch
# if match FALSE, follow the false branch
{
-name event_test
-start -time 08:00:00 AM
-action -onerror false_branch
-action -match -cron * * 1,2,3 * 2-6
-action -call true_branch
-action -inc 1 0 0 0
}
## true_branch
# If we get here and been_here=false
# 1. **do main work**
# 2. set event been_here=true
# if we get here and been_here=true
# 1. we will break from this routine (and in caller)
{
-name true_branch
-action -onerror break
-action -checkevent been_here
-action -print "Matched first weekday of the month at " %X%
-action -print "** do stuff here **"
-action -setevent been_here
}
## false_branch
# 1. clear the event
# 2. return to caller (and break from routine)
{
-name false_branch
-action -clearevent been_here
-action -return break
}
_________________________
Regards,
Luke Tomasello