'---------------------------------------------------------------------------- ' ' SampleCreateAlarms.vbs ' ' This VBScript demonstrates the powerful capabilities available ' when controlling Alarm++ through automation. ' ' It performs a number of manipulations on an alarm file and on ' the alarms it contains. ' '---------------------------------------------------------------------------- ' ' (c) 2002-2003, All Rights Reserved. ' 12noon, Stefan K. S. Tucker. ' (c) 1998-2002, All Rights Reserved. ' Perpetual Motion Software, Stefan K. S. Tucker. ' ' You have a royalty-free right to use, modify, reproduce and distribute ' the Sample Application Files (and/or any modified version) in any way you ' find useful, provided that you agree that 12noon has no warranty, ' obligations or liability for any Sample Application Files. ' '---------------------------------------------------------------------------- option explicit dim iValue iValue = MsgBox("This script runs Alarm++, creates an alarm file ""c:\Test.alm"", and manipulates it. Do you want to continue?", _ vbYesNo + vbExclamation, "12noon") if iValue = vbNo then WScript.Quit end if ' ' Declare some variables ' dim doc, app, alarms ' ' If this fails, the Alarm++ application is not registered. ' Run it once and try this script again. ' set doc = WScript.CreateObject("12noon.Alarm.Document") set app = doc.Application ' ' Register the application ' ' Enter the name and key provided to you, as a registered user. ' ' (You only need to do this when you receive a new version of ' Alarm++ and a new registration key for it.) ' 'if (app.Register("<>", "<>")) then ' WScript.Echo "Alarm++ registered successfully." 'else ' WScript.Echo "Alarm++ registration failed." 'end if app.New ' ' If we don't save the doc right away, adding ' an alarm prompts the user for a filename. ' doc.SaveAs("c:\Test.alm") ' If you want to see the alarm application window, comment out this line: 'app.Visible = True set alarms = doc.Alarms ' ' This starts with zero alarms defined. ' dim alarm set alarm = alarms.Add ' Show default name and message WScript.Echo "Default: name = " & alarm.Name & ", msg = " & alarm.Message ' Change name and message alarm.Name = "Test 1" alarm.Message = "Test message." ' Show new name and message WScript.Echo "New: name = " & alarm.Name & ", msg = " & alarm.Message ' ' A new alarm is initially disabled, ' so we have to give it a number of events. ' alarm.NumberOfEvents = 1 ' Show default event date/time WScript.Echo "Default: date/time = " & alarm.Date ' ' Set alarm for 16 December 1998 at 1pm. ' alarm.Date = DateValue("12/16/1998") alarm.Time = TimeValue("13:00:00") ' Show event date/time WScript.Echo "New: date/time = " & alarm.Date call DisplayAlarmCheckingStatus() ' ' Test repeat intervals ' call DisplayRepeatInterval() alarm.RepeatIntervalNumber = 5 alarm.RepeatIntervalMinutes = True call DisplayRepeatInterval() alarm.RepeatIntervalNumber = 15 alarm.RepeatIntervalHours = True call DisplayRepeatInterval() alarm.RepeatIntervalNumber = 25 alarm.RepeatIntervalDays = True call DisplayRepeatInterval() alarm.RepeatIntervalNumber = 35 alarm.RepeatIntervalWeeks = True call DisplayRepeatInterval() alarm.RepeatIntervalNumber = 45 alarm.RepeatIntervalMonths = True call DisplayRepeatInterval() alarm.RepeatIntervalNumber = 55 alarm.RepeatIntervalYears = True call DisplayRepeatInterval() ' ' Test snooze intervals ' call DisplaySnoozeInterval() alarm.SnoozeIntervalNumber = 5 alarm.SnoozeIntervalMinutes = True call DisplaySnoozeInterval() alarm.SnoozeIntervalNumber = 15 alarm.SnoozeIntervalHours = True call DisplaySnoozeInterval() alarm.SnoozeIntervalNumber = 25 alarm.SnoozeIntervalDays = True call DisplaySnoozeInterval() ' ' Test turning on alarm-checking ' alarms.CheckingAlarms = True call DisplayAlarmCheckingStatus() ' ' Test turning off alarm-checking ' alarms.CheckingAlarms = False call DisplayAlarmCheckingStatus() ' ' Loop through all alarms and display their names ' dim i for i = 0 to alarms.Count - 1 WScript.Echo "Alarm[" & i & "] is " & alarms.Item(i).Name next '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' WScript.Echo "The End" set alarms = Nothing app.Quit set app = Nothing set doc = Nothing '--------------------------------------------------------------- ' ' DisplayRepeatInterval ' ' This routine is used to display information about the passed ' alarm's repeat interval. ' '--------------------------------------------------------------- sub DisplayRepeatInterval() if (alarm.RepeatIntervalMinutes) then WScript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " minutes" else if (alarm.RepeatIntervalHours) then WScript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " hours" else if (alarm.RepeatIntervalDays) then WScript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " days" else if (alarm.RepeatIntervalWeeks) then WScript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " weeks" else if (alarm.RepeatIntervalMonths) then WScript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " months" else if (alarm.RepeatIntervalYears) then WScript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " years" end if end if end if end if end if end if end sub '--------------------------------------------------------------- ' ' DisplaySnoozeInterval ' ' This routine is used to display information about the passed ' alarm's snooze interval. ' '--------------------------------------------------------------- sub DisplaySnoozeInterval() if (alarm.SnoozeIntervalMinutes) then WScript.Echo "Snooze Interval: every " & alarm.SnoozeIntervalNumber & " minutes" else if (alarm.SnoozeIntervalHours) then WScript.Echo "Snooze Interval: every " & alarm.SnoozeIntervalNumber & " hours" else if (alarm.SnoozeIntervalDays) then WScript.Echo "Snooze Interval: every " & alarm.SnoozeIntervalNumber & " days" end if end if end if end sub '--------------------------------------------------------------- ' ' DisplayAlarmCheckingStatus ' ' This routine displays the status of alarm-checking. ' '--------------------------------------------------------------- sub DisplayAlarmCheckingStatus() if (alarms.CheckingAlarms) then WScript.Echo "Checking alarms: ENABLED" else WScript.Echo "Checking alarms: DISABLED" end if end sub