ReminderImpl.mesa. See Remember.Tioga for documentation and examples of how to use the Remember package.
Last Edited by: Teitelman, September 15, 1983 11:00 am
Last Edited by: Maxwell, January 6, 1984 2:09 pm
Last Edited by: Pier, March 13, 1984 7:19:19 pm PST
DIRECTORY
BasicTime USING [Now, Period, Update],
Commander USING [CommandProc, Register],
IO USING[PutRope, STREAM],
Clock USING [ChangeAllOffSets],
Process USING [Detach, Pause, SecondsToTicks],
RememberDefs,
RememberDefsPrivate USING [itIsNow, EnterEventMinder],
Rope USING[ROPE, Equal, Cat, Substr, Concat, Find],
PrincOpsUtils USING [IsBound],
Tempus USING [defaultTime, MakeRope, Packed, Parse, Unintelligible]
;
RememberUtilImpl: CEDAR MONITOR
IMPORTS BasicTime, Commander, IO, PrincOpsUtils, Process, Rope, Tempus, RememberDefsPrivate, Clock
SHARES RememberDefsPrivate, Clock
= BEGIN
ShowReminders: Commander.CommandProc = TRUSTED {
earlyRope, lateRope, err: Rope.ROPE;
earlyIndex: INT;
early, late: Tempus.Packed;
IF (earlyIndex ← Rope.Find[s1: cmd.commandLine, s2: "UpTo", case: FALSE])#-1 THEN {
earlyRope ← Rope.Substr[base: cmd.commandLine, len: earlyIndex];
lateRope ← Rope.Substr[base: cmd.commandLine, start: earlyIndex];
}
ELSE err ← "Syntax: ShowReminders <earliestTime> UpTo <latestTime>";
IF err=NIL THEN {
early ← Tempus.Parse[earlyRope, RememberDefsPrivate.itIsNow !
Tempus.Unintelligible => {
err ← SELECT ec FROM
invalid => "Invalid",
tooVague => "Too Vague",
overConstrained => "Over Constrained",
nothingSpecified => "Not a time",
notImplemented => "Not Implemented",
ENDCASE => ERROR;
IF vicinity # -1 THEN err ← Rope.Cat[
err,
": ",
Rope.Substr[base: rope, len: vicinity],
"<>",
Rope.Substr[base: rope, start: vicinity]
];
CONTINUE;
};
].time;
late ← Tempus.Parse[lateRope, RememberDefsPrivate.itIsNow !
Tempus.Unintelligible => {
err ← SELECT ec FROM
invalid => "Invalid",
tooVague => "Too Vague",
overConstrained => "Over Constrained",
nothingSpecified => "Not a time",
notImplemented => "Not Implemented",
ENDCASE => ERROR;
IF vicinity # -1 THEN err ← Rope.Cat[
err,
": ",
Rope.Substr[base: rope, len: vicinity],
"<>",
Rope.Substr[base: rope, start: vicinity]
];
CONTINUE;
};
].time;
};
IF err # NIL THEN cmd.err.PutRope[Rope.Concat[err, "\n"]]
ELSE {
IF PrincOpsUtils.IsBound[Clock.ChangeAllOffSets] THEN Clock.ChangeAllOffSets[BasicTime.Period[BasicTime.Now[], early]];
RememberDefsPrivate.EnterEventMinder[BasicTime.Update[early, 1], late]; -- + 1 so you can say remember .. at noon, then pretendits noon to see it get fired off
IF PrincOpsUtils.IsBound[Clock.ChangeAllOffSets] THEN Process.Detach[FORK LeaveItUpForAWhile[]];
cmd.out.PutRope[Rope.Cat[Tempus.MakeRope[time: early, includeDayOfWeek: TRUE], " UpTo ", Tempus.MakeRope[time: late, includeDayOfWeek: TRUE], "\n"]];
};
};
PretendIts: Commander.CommandProc = TRUSTED { -- for debugging
err: Rope.ROPE;
t: Tempus.Packed;
t ← Tempus.Parse[cmd.commandLine, RememberDefsPrivate.itIsNow !
Tempus.Unintelligible => {
err ← SELECT ec FROM
invalid => "Invalid",
tooVague => "Too Vague",
overConstrained => "Over Constrained",
nothingSpecified => "Not a time",
notImplemented => "Not Implemented",
ENDCASE => ERROR;
IF vicinity # -1 THEN err ← Rope.Cat[
err,
": ",
Rope.Substr[base: rope, len: vicinity],
"<>",
Rope.Substr[base: rope, start: vicinity]
];
CONTINUE;
};
].time;
IF err # NIL THEN cmd.err.PutRope[Rope.Concat[err, "\n"]]
ELSE {
IF PrincOpsUtils.IsBound[Clock.ChangeAllOffSets] THEN Clock.ChangeAllOffSets[BasicTime.Period[BasicTime.Now[], t]];
RememberDefsPrivate.EnterEventMinder[BasicTime.Update[t, 1]]; -- + 1 so you can say remember .. at noon, then pretendits noon to see it get fired off
IF PrincOpsUtils.IsBound[Clock.ChangeAllOffSets] THEN Process.Detach[FORK LeaveItUpForAWhile[]];
cmd.out.PutRope[Rope.Concat[Tempus.MakeRope[time: t, includeDayOfWeek: TRUE], "\n"]];
};
};
howLong: LONG CARDINAL ← 5;
LeaveItUpForAWhile: PROCEDURE = TRUSTED {
Process.Pause[Process.SecondsToTicks[howLong]];
Clock.ChangeAllOffSets[0];
};
ItIsNow: Commander.CommandProc = { -- for debugging
IF Rope.Equal[cmd.commandLine, "\n"] THEN {
RememberDefsPrivate.itIsNow ← Tempus.defaultTime;
cmd.out.PutRope[Rope.Concat["{current time}", "\n"]];
}
ELSE {
t: Tempus.Packed = Tempus.Parse[cmd.commandLine, RememberDefsPrivate.itIsNow].time;
RememberDefsPrivate.itIsNow ← BasicTime.Update[t, 1]; -- + 1 so you can say remember .. at noon, then pretendits noon to see it get fired off
cmd.out.PutRope[Rope.Concat[Tempus.MakeRope[time: t, includeDayOfWeek: TRUE], "\n"]];
};
};
Commander.Register["PretendIts", PretendIts, "Pretend its ... for purposes of posting a reminder. (A temporary change.)"];
Commander.Register["ShowReminders", ShowReminders, "ShowReminders <earliestTime> UpTo <latestTime>"];
Commander.Register["ShowRem", ShowReminders, "ShowReminders <earliestTime> UpTo <latestTime>"];
Commander.Register["ItIsNow", ItIsNow, "Pretend its ... for purposes of registration as well as posting a reminder. (A permanent change, i.e. must explicitly be restored by typing ItIsNow{cr})"];
END.
Edited on September 15, 1983 10:59 am, by Teitelman
changes pretendits to catch signals from tempus
changes to: PretendIts
Edited on January 6, 1984 2:08 pm, by Maxwell
changes to: DIRECTORY, IMPORTS, PretendIts, ItIsNow
Edited on January 24, 1984 8:06 pm, by Pier
changes to: DIRECTORY, PretendIts, ItIsNow
Edited on February 13, 1984 1:08:36 pm PST, by Pier
changes to: PretendIts, ItIsNow to add final CR to outputs
Edited on March 1, 1984 1:40:51 pm PST, by Pier
changes to: DIRECTORY, IMPORTS, SHARES, PretendIts, LeaveItUpForAWhile
Edited on March 13, 1984 6:15:50 pm PST, by Pier
Added ShowReminders
, DIRECTORY