WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Event Reminder Script

Keywords:  return the day and week in the month switch endswitch  

A pop-up window showing all upcoming important events. Put in StartUp folder or run daily from System Agent. Never forget anyone's birthday again!
Released to the public domain by Rik Blok , 1997.

This procedure requires four files: EventReminder.ini, EventReminder.wbt, GetDayWeek.wbt, and GetMonth.wbt.

  1. EventReminder.ini - for use with "EventReminder.wbt" to display important dates.

  2. EventReminder.wbt - reads "EventReminder.ini" to check for imminent events and displays them.

  3. GetDayWeek.wbt - a utility to return the day and week in the month of the date, passed in the "YY:MM:DD:HH:MM:SS" format. Returns the string in DayWeek. For example, returns "2ndSun" if date is the 2nd Sunday in the month. If no parameter passed then uses current date.

  4. GetMonth.wbt - a utility to return the month (in string format) of the date, passed in the "YY:MM:DD:HH:MM:SS" format. Returns the string in Month.

EventReminder.ini

;       EventReminder.ini - for use with "EventReminder.wbt" to display 
;               important dates.
;       Format:
;               [Month]
;               Date=event
;               1stDay=event
;               2ndDay=event
;               3rdDay=event
;               4thDay=event
;               5thDay=event
;               LastDay=event

[January]
1=New Year's Day

[February]
14=Valentine's Day

[March]
17=St. Patrick's Day

[April]
1=Muff's Birthday
27=Mike & Priscilla's Anniversary

[May]
2ndSun=Mother's Day

[June]
3rdSun=Father's Day

[July]
1=Canada Day

[September]
1stMon=Labour Day

[October]
2ndMon=Thanksgiving
31=Hallowe'en

[November]
11=Remembrance Day

[December]
25=Christmas

EventReminder.wbt

;	EventReminder.wbt - reads "EventReminder.ini" to check for imminent
;		events and displays them.
;	Released to the public domain by Rik Blok , 1997.

; Initialization
title = StrCat("Event Reminder on ", TimeDate())
WinTitle("",title)
lib = "Library\"							; subroutine library path
ini = StrCat(DirGet(),"EventReminder.ini")	; Ini file
msg = ""									; null message
date = TimeYmdHms()							; current date

; Build message
For i = 0 To 7					; next 7 days
	GoSub BuildEvent
	If event != ""
		msg = StrCat(msg,@CRLF,event)
		If i == 0 Then		msg = StrCat(msg," today!")
		Else If i==1 Then	msg = StrCat(msg," tomorrow.")
		Else If i<7 Then	msg = StrCat(msg," in %i% days.")
		Else			msg = StrCat(msg," in one week.")
	EndIf
	date = TimeAdd(date, "00:00:01:00:00:00")	; add one day
Next
date = TimeAdd(date,"00:00:06:00:00:00")	; synchronize at 2 weeks
For i = 2 To 4					; next 4 weeks
	GoSub BuildEvent
	If event != ""
		msg = StrCat(msg,@CRLF,event," in %i% weeks.")
	EndIf
	date = TimeAdd(date,"00:00:07:00:00:00")	; add one week
Next

; Display message
If msg != "" Then Message(title,msg)
Exit

:BuildEvent
; builds an event string for "date"
	Call("%lib%GetMonth.wbt",date)		; get month
	Call("%lib%GetDayWeek.wbt",date)	; get day/week in month (eg. "2ndSun")
	day = Int(ItemExtract(3,date,":"))	; get day in month
	; check for events as day of month and day/week of month
	countEvents = 0
	event = IniReadPvt(Month,day,"",ini)	; check for event
	If event != "" Then countEvents = countEvents + 1
	event2 = IniReadPvt(Month,DayWeek,"",ini)
	If event2 != "" Then countEvents = countEvents + 1

	; check if last DayWeek in month (eg. "LastMon")
	Call("%lib%GetDayWeek.wbt",TimeAdd(date,"00:00:07:00:00:00"))
	event3 = ""
	If StrSub(DayWeek,1,1) == 1
		DayWeek = StrCat("Last",StrSub(DayWeek,4,-1))
		event3 = IniReadPvt(Month,DayWeek,"",ini)
	EndIf
	If event3 != "" Then countEvents = countEvents + 1

	; merge events
	Switch countEvents
		Case 1
			event = StrCat(event,event2,event3)
			Break
		Case 2
			If event != ""
				event = StrCat(event," and ",event2,event3)
			Else
				event = StrCat(event2," and ",event3)
			EndIf
			Break
		Case 3
			event = StrCat(event,", ",event2, ", and ",event3)
			Break
	EndSwitch
Return 

GetDayWeek.wbt

;	GetDayWeek.wbt - a utility to return the day and week in the month
;		of the date, passed in the "YY:MM:DD:HH:MM:SS" format.	Returns
;		the string in DayWeek.	For example, returns "2ndSun" if date is
;		the 2nd Sunday in the month.  If no parameter passed then uses
;		current date.
Terminate(param0>1, "GetDayWeek", "Usage: GetDayWeek [YY:MM:DD<:HH:MM:SS>]")
If param0==0
	GetDayWeekDate = TimeYmdHms()
Else
	GetDayWeekDate = param1
EndIf

GetDayWeekList = "Sun Mon Tue Wed Thu Fri Sat"
; get day in week
GetDayWeekIndex = ItemLocate(StrSub(TimeDate(),1,3),GetDayWeekList," ") - 1
GetDayWeekIndex = (TimeDiffDays(GetDayWeekDate,TimeYmdHms()) + GetDayWeekIndex) mod 7
GetDayWeekDay = ItemExtract(GetDayWeekIndex+1,GetDayWeekList," ")

; get week in month
GetDayWeekWeek = (ItemExtract(3,GetDayWeekDate,":") - 1) / 7 + 1
; append suffix (eg. "1" --> "1st")
GetDayWeekWeek = StrCat(GetDayWeekWeek,ItemExtract(GetDayWeekWeek,"st nd rd th th"," "))

DayWeek = StrCat(GetDayWeekWeek,GetDayWeekDay)
Drop(GetDayWeekDate,GetDayWeekDay,GetDayWeekWeek,GetDayWeekIndex,GetDayWeekList)
Return

GetMonth.wbt

;	GetMonth.wbt - a utility to return the month (in string format) of 
;		the date, passed in the "YY:MM:DD:HH:MM:SS" format.  Returns
;		the string in Month.

Terminate(param0>1, "GetMonth","Usage: GetMonth [YY:MM:DD:HH:MM:SS]")
If param0 == 0
	GetMonthDate = TimeYmdHms()
Else
	GetMonthDate = param1
EndIf

Switch Int(ItemExtract(2,GetMonthDate,":"))
	case 1
		Month = "January"
		break
	case 2
		Month = "February"
		break
	case 3
		Month = "March"
		break
	case 4	
		Month = "April"
		break
	case 5
		Month = "May"
		break
	case 6
		Month = "June"
		break
	case 7
		Month = "July"
		break
	case 8
		Month = "August"
		break
	case 9
		Month = "September"
		break
	case 10
		Month = "October"
		break
	case 11
		Month = "November"
		break
	case 12
		Month = "December"
		break
EndSwitch
Drop(GetMonthDate)
Return

Article ID:   W13777
Filename:   Event Reminder Script.txt
File Created: 1999:04:15:16:56:18
Last Updated: 1999:04:15:16:56:18