ALARM

Version 1.0.0.1 (4.02 KB) by Jiro Doke
An alarm function that displays a dialog box after a set length of time.
4.3K Downloads
Updated Thu, 01 Sep 2016 15:04:32 +0000

View License

ALARM Displays an alarm message after a set time.
ALARM(T, MSG) displays a message after T seconds with a text message MSG. After T seconds, the computer will start beeping and display a dialog box with an option to Snooze. The beeping will stop after one minute or when the dialog box is closed. The snooze interval is 5 minutes and up to 10 snoozes are allowed. These values can be changed by ALARM(T, MSG, PROP, VAL, ...) where PROP can be one of the two:

'SnoozeInt' : snooze interval in seconds (default: 300)
'SnoozeCount' : number of maximum snoozes (default: 10)

T can also be a string of a specific time for the alarm. The string may be any of the following formats:
HH:MM, HH:MM:SS, HH:MM PM, HH:MM:SS PM.
If the date is specified, it is ignored. The alarm will go off at the next possible HH:MM:SS.

The dialog box is a QUESTDLG, which means that all execution will be halted until the user selects one of the buttons.

ALARM by itself will list all active alarms. It will display whether the alarm has not yet gone off (pending) or has been snoozed, the time til the next alarm, and the alarm message.

ALARM('-delete') will display the active alarms and give the option of deleting any of the alarms.

When an ALARM is initially defined, it can return the number of seconds before it will go off. Use semicolon to suppress this output.

This code uses a timer object, and it will delete itself once the alarm is turned off. Note that the timer can be deleted. When MATLAB closes, it will also be deleted and will NOT be restored at the next session. The purpose of this code is for a simple time reminder function for those long coding sessions one might have.

Example:
% alarm in 60 seconds
alarm(60, 'You can stop waiting now');

% alarm at 9 PM
alarm('9:00 PM', 'It''s 9 PM!!');

% snooze time of 3 minutes for a max of 5 snoozes
alarm(120, 'Hello!', 'SnoozeInt', 180, 'SnoozeCount', 5);

Cite As

Jiro Doke (2024). ALARM (https://www.mathworks.com/matlabcentral/fileexchange/9018-alarm), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14SP2
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.1

Updated license

1.0.0.0

Minor bug fixes and added examples in the help.