Fwd Motion
02-24-2012, 06:57 AM
Wrote this just messing around and I ended up using it! Just thought I'd share, haha
program Alarm; // By Fwd Motion
const
{*****************EDIT PREFERENCES HERE**************}
AlarmHour = '09'; //Hour to sound alarm! If it is a single digit, add a 0!
AlarmMinute = '45'; //Minute to sound alarm! If it is a single digit, add a 0!
AMorPM = 'AM'; //AM or PM?
AlarmPath = 'C:/Simba/Scripts/alarmclock.wav'; //Alarm Path
{**********************END SETUP*********************}
function TheTime: string;
var
Hour, Mins, Sec, MSec: Word;
PAM: string;
begin
DecodeTime(Now, Hour, Mins, Sec, MSec);
PAM := 'AM';
if (Hour > 12) then
begin
Hour := Hour - 12;
PAM := 'PM';
end else if (Hour = 12) then
PAM := 'PM'
else if (Hour = 0) then
Hour := 12;
Result := (Padz(IntToStr(Hour), 2) + ':' + Padz(IntToStr(Mins), 2) + ':' + Padz(IntToStr(Sec), 2) + ' ' + PAM);
end;
procedure SOUNDTHEALARM;
begin
repeat
sleep(500);
until TheTime >= (AlarmHour + ':' + AlarmMinute + ':00 ' + AMorPM);
if TheTime >= (AlarmHour + ':' + AlarmMinute + ':00 ' + AMorPM) then
begin
repeat
PlaySound(AlarmPath);
writeln('WakeUp!!!');
sleep(3000);
StopSound;
until (TheTime > (inttostr(strtoint(AlarmHour)+1)) + ':' + AlarmMinute + ':00 ' + AMorPM);
end;
end;
begin
SOUNDTHEALARM;
end.
program Alarm; // By Fwd Motion
const
{*****************EDIT PREFERENCES HERE**************}
AlarmHour = '09'; //Hour to sound alarm! If it is a single digit, add a 0!
AlarmMinute = '45'; //Minute to sound alarm! If it is a single digit, add a 0!
AMorPM = 'AM'; //AM or PM?
AlarmPath = 'C:/Simba/Scripts/alarmclock.wav'; //Alarm Path
{**********************END SETUP*********************}
function TheTime: string;
var
Hour, Mins, Sec, MSec: Word;
PAM: string;
begin
DecodeTime(Now, Hour, Mins, Sec, MSec);
PAM := 'AM';
if (Hour > 12) then
begin
Hour := Hour - 12;
PAM := 'PM';
end else if (Hour = 12) then
PAM := 'PM'
else if (Hour = 0) then
Hour := 12;
Result := (Padz(IntToStr(Hour), 2) + ':' + Padz(IntToStr(Mins), 2) + ':' + Padz(IntToStr(Sec), 2) + ' ' + PAM);
end;
procedure SOUNDTHEALARM;
begin
repeat
sleep(500);
until TheTime >= (AlarmHour + ':' + AlarmMinute + ':00 ' + AMorPM);
if TheTime >= (AlarmHour + ':' + AlarmMinute + ':00 ' + AMorPM) then
begin
repeat
PlaySound(AlarmPath);
writeln('WakeUp!!!');
sleep(3000);
StopSound;
until (TheTime > (inttostr(strtoint(AlarmHour)+1)) + ':' + AlarmMinute + ':00 ' + AMorPM);
end;
end;
begin
SOUNDTHEALARM;
end.