SRL Archive - Non-RuneScape Scripts

An Alarm! (:


Fwd Motion

2012-02-24 01:57:52

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.

P1nky

2012-02-24 02:47:13

Neat :), I remember when i was beginning to learn how to script, I attempted to make a alarm but horribly failed :(

Good Job.

Mushini

2012-02-24 02:58:43

Alarm is useful!

Fwd Motion

2012-02-24 03:02:09

I made this in a matter of like 10 minutes :P

By making this script, I learned that pascal, for some reason, uses a bunch of seemingly random numbers for the time, so the time almost literally needs to be decoded

I also learned that you can do (inttostr(strtoint('string')+1); Which is pretty cool :P

RyGuy

2012-02-24 10:16:28

Cool utility, but I think I'm gonna stick to my phone for now :P