_TITLE "Time Calculator" ' I do wonder if I should start planning before I begin to code... 'Author: Jaze James McAskill (mcaskilljaze@gmail.com)
'License: Freeware if anyone can remember what that is.
' All I ask is that if you copy part or all
' of this code you keep my name on it
CONST DownKeyHit%
= 20480 CONST LeftKeyHit%
= 19200 CONST RightKeyHit%
= 19712
HaltAndDisplay% = 0: UserCommand$ = "": HeaderCopy$ = "": Instructions$ = "": HighlightedOption% = 0
yPos% = 0: xPos% = 0: GDTMonth% = 0: GDTDay% = 0: GDTYear% = 0: O% = 0: OP$ = "": MaxOption% = 0
GDTHours% = 0: GDTMinutes% = 0: GDTSeconds% = 0: GDTRtn$ = ""
MW$ = "": SomeKey% = 0: TimerStarted% = 0: FirstTime% = 0: Increment% = 0: TimeElapsed% = 0
HaltAndDisplay% = TRUE: yPos% = 15: xPos% = 17: HighlightedOption% = 1: MaxOption% = 6
TimerStarted% = FALSE%: Increment% = 1
IF HaltAndDisplay%
= TRUE%
THEN xPos% = 17: yPos% = 15
HeaderCopy$ = Header$
COLOR 12, 1: Instructions$
= "Use the arrow keys to select the date and time - Push " Instructions$
= Instructions$
+ CHR$(34) + "X" + CHR$(34) + " to exit to the system - Push [ESC] to reset - Push [ENTER] to confirm" LOCATE 46, 1:
PRINT LongCenter$
(Instructions$
, 50, FALSE
)
MW$
= "": MW$
= MonthWord$
(GDTMonth%
- 1):
COLOR 14, 1 LOCATE yPos%
- 2, CenterBetween
(MW$
, xPos%
- 3, xPos%
+ 8):
PRINT MW$
MW$
= "": MW$
= MonthWord$
(GDTMonth%
):
COLOR 10, 0 LOCATE yPos%
, CenterBetween
(MW$
, xPos%
- 3, xPos%
+ 8):
PRINT MW$
MW$
= "": MW$
= MonthWord$
(GDTMonth%
+ 1):
COLOR 14, 1 LOCATE yPos%
+ 2, CenterBetween
(MW$
, xPos%
- 3, xPos%
+ 8):
PRINT MW$
LOCATE yPos%
- 5, xPos%
+ 20:
IF HighlightedOption%
= 2 THEN COLOR 14, 1: O%
= 0: O%
= CorrectDay
(GDTMonth%
, GDTDay%
- 1, GDTYear%
) OP$ = "": OP$ = S$(O%) + Suffix$(O%)
LOCATE yPos%
- 2, CenterBetween
(OP$
, xPos%
+ 19, xPos%
+ 22):
PRINT OP$
COLOR 10, 0: OP$
= "": O%
= 0: OP$
= S$
(GDTDay%
) + Suffix$
(GDTDay%
) LOCATE yPos%
, CenterBetween
(OP$
, xPos%
+ 19, xPos%
+ 22):
PRINT OP$
COLOR 14, 1: O%
= 0: O%
= CorrectDay
(GDTMonth%
, GDTDay%
+ 1, GDTYear%
) OP$ = "": OP$ = S$(O%) + Suffix$(O%)
LOCATE yPos%
+ 2, CenterBetween
(OP$
, xPos%
+ 19, xPos%
+ 22):
PRINT OP$
LOCATE yPos%
- 5, xPos%
+ 40:
IF HighlightedOption%
= 3 THEN COLOR 14, 1: O%
= 0: O%
= GDTYear%
- 1:
IF O%
= -1 THEN O%
= 9999 LOCATE yPos%
- 2, CenterBetween
(S$
(O%
), xPos%
+ 40, xPos%
+ 44):
PRINT S$
(O%
) COLOR 10, 0:
LOCATE yPos%
, CenterBetween
(S$
(GDTYear%
), xPos%
+ 40, xPos%
+ 44):
PRINT S$
(GDTYear%
) COLOR 14, 1: O%
= 0: O%
= GDTYear%
+ 1:
IF O%
> 9999 THEN O%
= 0 LOCATE yPos%
+ 2, CenterBetween
(S$
(O%
), xPos%
+ 40, xPos%
+ 44):
PRINT S$
(O%
)
COLOR 10, 1: a$
= "": a$
= WrittenOutDate$
(GDTMonth%
, GDTDay%
, GDTYear%
) + " at " + ClockString$
(GDTHours%
, GDTMinutes%
, GDTSeconds%
)
yPos% = yPos% + 21
IF HighlightedOption%
= 4 THEN IF GDTHours%
+ 1 >= 1 AND GDTHours%
+ 1 < 13 THEN
IF HighlightedOption%
= 5 THEN PRINT S$
(GDTMinutes%
- 1) IF GDTMinutes%
+ 1 >= 0 AND GDTMinutes%
+ 1 <= 59 THEN PRINT S$
(GDTMinutes%
+ 1)
IF HighlightedOption%
= 6 THEN PRINT S$
(GDTSeconds%
- 1) IF gdtseonds%
+ 1 >= 0 AND GDTSeconds%
+ 1 <= 59 THEN PRINT S$
(GDTSeconds%
+ 1)
IF GDTHours%
- 1 >= 0 AND GDTHours%
- 1 <= 11 THEN IF GDTHours%
+ 1 >= 0 AND GDTHours%
+ 1 <= 11 OR GDTHours%
+ 1 = 24 THEN
HaltAndDisplay% = FALSE
IF SomeKey%
= UpKeyHit%
OR SomeKey%
= DownKeyHit%
THEN IF TimerStarted%
= FALSE%
THEN TimerStarted% = TRUE%
FirstTime% = 0
Increment% = 1
TimeElapsed% = 0
TimerStarted% = FALSE%
IF HighlightedOption%
= 2 THEN Increment%
= 2 'Day IF HighlightedOption%
= 3 THEN Increment%
= 10 'Year IF HighlightedOption%
= 5 THEN Increment%
= 2 'minutes IF HighlightedOption%
= 6 THEN Increment%
= 2 'seconds IF HighlightedOption%
= 3 THEN Increment%
= 25 IF HighlightedOption%
= 3 THEN Increment%
= 50
HighlightedOption% = HighlightedOption% - 1
IF HighlightedOption%
= 0 THEN HighlightedOption%
= MaxOption%
HaltAndDisplay% = TRUE%
HighlightedOption% = HighlightedOption% + 1
IF HighlightedOption%
> MaxOption%
THEN HighlightedOption%
= 1 HaltAndDisplay% = TRUE%
IF HighlightedOption%
= 1 THEN GDTMonth% = GDTMonth% - Increment%
IF GDTMonth%
<= 0 THEN GDTMonth%
= 12 IF GDTMonth%
= 4 OR GDTMonth%
= 6 OR GDTMonth%
= 9 OR GDTMonth%
= 11 THEN IF GDTDay%
= 31 THEN GDTDay%
= 30:
GDTDay% = 29
GDTDay% = GDTDay% - Increment%
IF GDTMonth%
= 4 OR GDTMonth%
= 6 OR GDTMonth%
= 9 OR GDTMonth%
= 11 THEN GDTDay% = 30
GDTYear% = GDTYear% - Increment%
IF GDTYear%
< 0 THEN GDTYear%
= 9999 GDTDay% = CorrectDay%(GDTMonth%, GDTDay%, GDTYear%)
GDTHours% = GDTHours% - 1
IF GDTHours%
< 0 THEN GDTHours%
= 23 GDTMinutes% = GDTMinutes% - Increment%
IF GDTMinutes%
< 0 THEN GDTMinutes%
= 59 GDTSeconds% = GDTSeconds% - Increment%
IF GDTSeconds%
< 0 THEN GDTSeconds%
= 59 HaltAndDisplay% = TRUE%
IF HighlightedOption%
= 1 THEN GDTMonth% = GDTMonth% + Increment%
IF GDTMonth%
> 12 THEN GDTMonth%
= 1 GDTDay% = CorrectDay%(GDTMonth%, GDTDay%, GDTYear%)
GDTDay% = GDTDay% + Increment%
IF GDTDay%
>= 29 THEN GDTDay%
= CorrectDay
(GDTMonth%
, GDTDay%
, GDTYear%
) GDTYear% = GDTYear% + Increment%
IF GDTYear%
> 9999 THEN GDTYear%
= 0 GDTDay% = CorrectDay%(GDTMonth%, GDTDay%, GDTYear%)
GDTHours% = GDTHours% + 1
IF GDTHours%
= 24 THEN GDTHours%
= 0 GDTMinutes% = GDTMinutes% + Increment%
IF GDTMinutes%
>= 60 THEN GDTMinutes%
= 0 GDTSeconds% = GDTSeconds% + Increment%
IF GDTSeconds%
>= 60 THEN GDTSeconds%
= 0 HaltAndDisplay% = TRUE%
HaltAndDisplay% = TRUE%
GDTRtn$ = ""
GDTRtn$ = "000"
GDTRtn$ = GDTRtn$ + S$(GDTYear%) + ":"
tempDay% = 0: tempDay% = DaysPassedJanFromMonthDayYear(GDTMonth%, GDTDay%, GDTYear%)
GDTRtn$ = GDTRtn$ + "00"
GDTRtn$ = GDTRtn$ + S$(tempDay%) + ":"
IF GDTHours%
< 10 THEN GDTRtn$
= GDTRtn$
+ "0" GDTRtn$ = GDTRtn$ + S$(GDTHours%) + ":"
IF GDTMinutes%
< 10 THEN GDTRtn$
= GDTRtn$
+ "0" GDTRtn$ = GDTRtn$ + S$(GDTMinutes%) + ":"
IF GDTSeconds%
< 10 THEN GDTRtn$
= GDTRtn$
+ "0" GDTRtn$ = GDTRtn$ + S$(GDTSeconds%)
GetDateAndTime$ = GDTRtn$
FUNCTION ClockString$
(CSHours%
, CSMinutes%
, CSSeconds%
) DisplayHours$ = "": CSRtn$ = "": AmPm$ = ""
DisplayHours$ = "12"
AmPm$ = "AM"
DisplayHours$ = S$(CSHours%)
AmPm$ = "AM"
DisplayHours$ = "12"
AmPm$ = "PM"
DisplayHours$ = S$(CSHours% - 12)
AmPm$ = "PM"
CSRtn$ = DisplayHours$ + ":"
IF CSMinutes%
< 10 THEN CSRtn$
= CSRtn$
+ "0" CSRtn$ = CSRtn$ + S$(CSMinutes%) + " " + AmPm$ + " and " + S$(CSSeconds%) + " second"
IF CSSeconds%
<> 1 THEN CSRtn$
= CSRtn$
+ "s"
ClockString$ = CSRtn$
xPos% = 0: yPos% = 0: MaxOption% = 0: HighlightedOption% = 0
HaltAndDisplay% = 0: UserCommand$ = "": Instructions$ = "": TimerStarted% = 0: FirstTime% = 0: TimeElapsed% = 0
GDMonth% = 0: GDDay% = 0: GDYear% = 0: MW$ = "": Increment% = 0: MinOption% = 0: HeaderCopy$ = "": GDRtn$ = ""
HaltAndDisplay% = TRUE%: yPos% = 22: xPos% = 19: HighlightedOption% = 1: Increment% = 1
MaxOption% = 3: MinOption% = 1: HeaderCopy$ = Header$
TimerStarted% = FALSE
IF HaltAndDisplay%
= TRUE%
THEN HeaderCopy$ = Header$
COLOR 12, 1: Instructions$
= "Use the arrow keys to select the date - Push [ESC] to reset - Push " Instructions$
= Instructions$
+ CHR$(34) + "X" + CHR$(34) + " to exit to the system - " Instructions$ = Instructions$ + "Push [ENTER] when you have selected the desired date"
LOCATE yPos%
+ 20, 1:
PRINT LongCenter$
(Instructions$
, 60, FALSE%
)
MW$
= "": MW$
= MonthWord$
(GDMonth%
- 1):
COLOR 14, 1 LOCATE yPos%
- 2, CenterBetween
(MW$
, xPos%
- 3, xPos%
+ 8):
PRINT MW$
MW$
= "": MW$
= MonthWord$
(GDMonth%
):
COLOR 10, 0 LOCATE yPos%
, CenterBetween
(MW$
, xPos%
- 3, xPos%
+ 8):
PRINT MW$
MW$
= "": MW$
= MonthWord$
(GDMonth%
+ 1):
COLOR 14, 1 LOCATE yPos%
+ 2, CenterBetween
(MW$
, xPos%
- 3, xPos%
+ 8):
PRINT MW$
LOCATE yPos%
- 5, xPos%
+ 20:
IF HighlightedOption%
= 2 THEN COLOR 14, 1: O%
= 0: O%
= CorrectDay
(GDMonth%
, GDDay%
- 1, GDYear%
) OP$ = "": OP$ = S$(O%) + Suffix$(O%)
LOCATE yPos%
- 2, CenterBetween
(OP$
, xPos%
+ 19, xPos%
+ 22):
PRINT OP$
COLOR 10, 0: OP$
= "": O%
= 0: OP$
= S$
(GDDay%
) + Suffix$
(GDDay%
) LOCATE yPos%
, CenterBetween
(OP$
, xPos%
+ 19, xPos%
+ 22):
PRINT OP$
COLOR 14, 1: O%
= 0: O%
= CorrectDay
(GDMonth%
, GDDay%
+ 1, GDYear%
) OP$ = "": OP$ = S$(O%) + Suffix$(O%)
LOCATE yPos%
+ 2, CenterBetween
(OP$
, xPos%
+ 19, xPos%
+ 22):
PRINT OP$
LOCATE yPos%
- 5, xPos%
+ 40:
IF HighlightedOption%
= 3 THEN COLOR 14, 1: O%
= 0: O%
= GDYear%
- 1:
IF O%
= -1 THEN O%
= 9999 LOCATE yPos%
- 2, CenterBetween
(S$
(O%
), xPos%
+ 40, xPos%
+ 44):
PRINT S$
(O%
) COLOR 10, 0:
LOCATE yPos%
, CenterBetween
(S$
(GDYear%
), xPos%
+ 40, xPos%
+ 44):
PRINT S$
(GDYear%
) COLOR 14, 1: O%
= 0: O%
= GDYear%
+ 1:
IF O%
> 9999 THEN O%
= 0 LOCATE yPos%
+ 2, CenterBetween
(S$
(O%
), xPos%
+ 40, xPos%
+ 44):
PRINT S$
(O%
)
COLOR 10, 0: a$
= "": a$
= WrittenOutDate$
(GDMonth%
, GDDay%
, GDYear%
)
HaltAndDisplay% = FALSE%
IF SomeKey%
= UpKeyHit%
OR SomeKey%
= DownKeyHit%
THEN IF TimerStarted%
= FALSE%
THEN TimerStarted% = TRUE%
FirstTime% = 0
Increment% = 1
TimeElapsed% = 0
TimerStarted% = FALSE%
IF HighlightedOption%
= 3 THEN Increment%
= 15 IF HighlightedOption%
= 2 THEN Increment%
= 2 IF HighlightedOption%
= 3 THEN Increment%
= 25 IF HighlightedOption%
= 3 THEN Increment%
= 35 IF HighlightedOption%
= 3 THEN Increment%
= 65
IF HighlightedOption%
= 1 THEN GDMonth% = GDMonth% - Increment%
IF GDMonth%
<= 0 THEN GDMonth%
= 12 IF GDMonth%
= 4 OR GDMonth%
= 6 OR GDMonth%
= 9 OR GDMonth%
= 11 THEN IF GDDay%
= 31 THEN GDDay%
= 30:
GDDay% = 29
GDDay% = GDDay% - Increment%
IF GDMonth%
= 4 OR GDMonth%
= 6 OR GDMonth%
= 9 OR GDMonth%
= 11 THEN GDDay% = 30
GDYear% = GDYear% - Increment%
IF GDYear%
< 0 THEN GDYear%
= 9999 GDDay% = CorrectDay%(GDMonth%, GDDay%, GDYear%)
HaltAndDisplay% = TRUE%
IF HighlightedOption%
= 1 THEN GDMonth% = GDMonth% + Increment%
IF GDMonth%
> 12 THEN GDMonth%
= 1 GDDay% = CorrectDay%(GDMonth%, GDDay%, GDYear%)
GDDay% = GDDay% + Increment%
IF GDDay%
>= 29 THEN GDDay%
= CorrectDay
(GDMonth%
, GDDay%
, GDYear%
) GDYear% = GDYear% + Increment%
IF GDYear%
> 9999 THEN GDYear%
= 0 GDDay% = CorrectDay%(GDMonth%, GDDay%, GDYear%)
HaltAndDisplay% = TRUE%
HighlightedOption% = HighlightedOption% + 1
IF HighlightedOption%
> MaxOption%
THEN HighlightedOption%
= MinOption%
HaltAndDisplay% = TRUE%
HighlightedOption% = HighlightedOption% - 1
IF HighlightedOption%
< MinOption%
THEN HighlightedOption%
= MaxOption%
HaltAndDisplay% = TRUE%
GDRtn$ = ""
GDRtn$ = MakeFormattedDATE$(GDMonth%, GDDay%, GDYear%)
GetDate$ = GDRtn$
FUNCTION MakeFormattedDATE$
(MFMonth%
, MFDay%
, MFYear%
) MFDRtn$ = ""
IF MFMonth%
< 10 THEN MFDRtn$
= "0" MFDRtn$ = MFDRtn$ + S$(MFMonth%) + "/"
IF MFDay%
< 10 THEN MFDRtn$
= MFDRtn$
+ "0" MFDRtn$ = MFDRtn$ + S$(MFDay%) + "/"
MFDRtn$ = MFDRtn$ + "000"
ELSEIF MFYear%
>= 10 AND MFYear%
< 100 THEN MFDRtn$
= MFDRtn$
+ "00" MFDRtn$ = MFDRtn$ + S$(MFYear%)
MakeFormattedDATE$ = MFDRtn$
FUNCTION WrittenOutDate$
(WODMonth%
, WODDay%
, WODYear%
) WODRtn$ = ""
WODRtn$ = MonthWord$(WODMonth%)
WODRtn$ = WODRtn$ + " "
WODRtn$ = WODRtn$ + S$(WODDay%) + Suffix(WODDay%)
WODRtn$ = WODRtn$ + ", "
WODRtn$ = WODRtn$ + S$(WODYear%)
WrittenOutDate$ = WODRtn$
FUNCTION CorrectDay%
(CDMonth%
, CDDay%
, CDYear%
) CDRtn% = 0
IF CDMonth%
= 1 OR CDMonth%
= 3 OR CDMonth%
= 5 OR CDMonth%
= 7 OR CDMonth%
= 8 OR CDMonth%
= 10 OR CDMonth%
= 12 THEN CDRtn% = 31
CDRtn% = 30
CDRtn% = 1
IF CDMonth%
= 4 OR CDMonth%
= 6 OR CDMonth%
= 9 OR CDMonth%
= 11 THEN CDRtn% = 1
CDRtn% = 1
CDRtn% = CDDay%
CorrectDay% = CDRtn%
FUNCTION CenterBetween%
(text$
, MinX%
, MaxX%
) CBRtn% = 0
CBRtn% = MinX%
CBRtn%
= INT((MaxX%
- MinX%
- LEN(text$
)) / 2) + MinX%
CenterBetween = CBRtn%
FNUMonth% = 0: FNUDay% = 0: FNUYear% = 0: FNUHour% = 0: FNUMinute% = 0: FNUSecond% = 0
FNUHeader$ = "": FNUTargetFormatDATE$ = "": FNUTargetMonth% = 0: FNUTargetDay% = 0: FNUTargetYear% = 0
FNUTargetFormatTIME$ = "": FNUTargetHour% = 0: FNUTargetMinute% = 0: FNUTargetSecond% = 0: FNUTargetDayCopy% = 0
FNUFinalDay% = 0: FNUFinalMonth% = 0: FNUFinalYear% = 0: FNUFinalHour% = 0: FNUFinalMinute% = 0: FNUFinalSecond% = 0
a$ = "": LeftChar$ = ""
FNUDay% = DaysPassedJanFromMonthDayYear(FNUMonth%, FNUDay%, FNUYear%)
FNUHeader$ = "Select A Target Date$"
FNUTargetFormatDATE$ = GetDate$(FNUHeader$)
FNUTargetMonth%
= VAL(LEFT$(FNUTargetFormatDATE$
, 2)) FNUTargetDay%
= VAL(MID$(FNUTargetFormatDATE$
, 4, 2)) FNUTargetDayCopy% = FNUTargetDay%
FNUTargetYear%
= VAL(RIGHT$(FNUTargetFormatDATE$
, 4)) FNUTargetDay% = DaysPassedJanFromMonthDayYear(FNUTargetMonth%, FNUTargetDay%, FNUTargetYear%)
FNUHeader$ = ""
FNUHeader$ = "Select A Target Time On " + WrittenOutDate$(FNUTargetMonth%, FNUTargetDayCopy%, FNUTargetYear%)
FNUTargetFormatTIME$ = GetTime$(FNUHeader$)
FNUTargetHour%
= VAL(LEFT$(FNUTargetFormatTIME$
, 2)) FNUTargetMinute%
= VAL(MID$(FNUTargetFormatTIME$
, 4, 4)) FNUTargetSecond%
= VAL(RIGHT$(FNUTargetFormatTIME$
, 2))
FNUFinalSecond% = FNUTargetSecond% - FNUSecond%
FNUTargetMinute% = FNUTargetMinute% - 1
FNUFinalSecond% = FNUFinalSecond% + 60
FNUFinalMinute% = FNUTargetMinute% - FNUMinute%
FNUTargetHour% = FNUTargetHour% - 1
FNUFinalMinute% = FNUFinalMinute% + 60
FNUFinalHour% = FNUTargetHour% - FNUHour%
FNUFinalHour% = FNUFinalHour% + 60
FNUTargetDay% = FNUTargetDay% - 1
FNUFinalDay% = FNUTargetDay% - FNUDay%
FNUFinalDay% = FNUFinalDay% + 366
FNUTargetYear% = FNUTargetYear% - 1
FNUFinalYear% = FNUTargetYear% - FNUYear%
a$ = "": a$ = "The selected date and time is before now"
a$ = "": a$ = MakeElapsedTimeShort$(FNUFinalYear%, FNUFinalDay%, FNUFinalHour%, FNUFinalMinute%, FNUFinalSecond%)
a$ = ElapsedTimeWrittenOut$(a$)
b$ = "There is"
a$ = "": a$ = WrittenOutDate$(FNUTargetMonth%, FNUTargetDayCopy%, FNUTargetYear%)
a$ = "": a$ = ClockString$(FNUTargetHour%, FNUTargetMinute%, FNUTargetSecond%)
a$ = "": a$ = "Hit any key to continue"
FUNCTION MakeElapsedTimeShort$
(MEYears%
, MEDays%
, MEHours%
, MEMinutes%
, MESeconds%
) METSRtn$ = ""
METSRtn$ = "000"
METSRtn$ = METSRtn$ + S$(MEYears%) + ":"
METSRtn$ = METSRtn$ + "00"
METSRtn$
= METSRtn$
+ "0":
END IF METSRtn$ = METSRtn$ + S$(MEDays%) + ":"
IF MEHours%
< 10 THEN METSRtn$
= METSRtn$
+ "0" METSRtn$ = METSRtn$ + S$(MEHours%) + ":"
IF MEMinutes%
< 10 THEN METSRtn$
= METSRtn$
+ "0" METSRtn$ = METSRtn$ + S$(MEMinutes%) + ":"
IF MESeconds%
< 10 THEN METSRtn$
= METSRtn$
+ "0" METSRtn$ = METSRtn$ + S$(MESeconds%)
MakeElapsedTimeShort$ = METSRtn$
FUNCTION ElapsedTimeWrittenOut$
(TimeShortString$
) ETWORtn$ = "": Years3% = 0: Days3% = 0: Hours3% = 0: Minutes3% = 0: Seconds3% = 0
Years3%
= VAL(LEFT$(TimeShortString$
, 4)) Days3%
= VAL(MID$(TimeShortString$
, 6, 3)) Hours3%
= VAL(MID$(TimeShortString$
, 10, 2)) Minutes3%
= VAL(MID$(TimeShortString$
, 13, 2))
lftNum%
= INT(Years3%
/ 1000) ETWORtn$ = S$(lftNum%) + ","
rtNum% = Years3% - (lftNum% * 1000)
ETWORtn$ = ETWORtn$ + "00"
ETWORtn$ = ETWORtn$ + "0"
ETWORtn$ = ETWORtn$ + S$(rtNum%)
ETWORtn$ = S$(Years3%)
ETWORtn$ = ETWORtn$ + " Year"
IF Years3%
<> 1 THEN ETWORtn$
= ETWORtn$
+ "s" IF Days3%
<> 0 AND (Hours3%
<> 0 OR Minutes3%
<> 0 OR Seconds3%
<> 0) THEN ETWORtn$ = ETWORtn$ + ", "
ETWORtn$ = ETWORtn$ + " and "
ETWORtn$ = ETWORtn$ + ", "
ETWORtn$ = ETWORtn$ + " and "
ETWORtn$ = ETWORtn$ + ", "
ETWORtn$ = ETWORtn$ + " and "
ETWORtn$ = ETWORtn$ + S$(Days3%) + " Day"
IF Days3%
<> 1 THEN ETWORtn$
= ETWORtn$
+ "s" IF Hours3%
<> 0 AND (Minutes3%
<> 0 OR Seconds3%
<> 0) THEN ETWORtn$ = ETWORtn$ + ", "
ETWORtn$ = ETWORtn$ + " and "
ETWORtn$ = ETWORtn$ + ", "
ETWORtn$ = ETWORtn$ + " and "
ETWORtn$ = ETWORtn$ + S$(Hours3%) + " hour"
IF Hours3%
<> 1 THEN ETWORtn$
= ETWORtn$
+ "s" ETWORtn$ = ETWORtn$ + ", "
ETWORtn$ = ETWORtn$ + " and "
ETWORtn$ = ETWORtn$ + S$(Minutes3%) + " minute"
IF Minutes3%
<> 1 THEN ETWORtn$
= ETWORtn$
+ "s" IF Seconds3%
<> 0 THEN ETWORtn$
= ETWORtn$
+ " and " ETWORtn$ = ETWORtn$ + S$(Seconds3%) + " second"
IF Seconds3%
<> 1 THEN ETWORtn$
= ETWORtn$
+ "s" IF Years3%
= 0 AND Days3%
= 0 AND Hours3%
= 0 AND Minutes3%
= 0 AND Seconds3%
= 0 THEN ETWORtn$
= "Nothing" ElapsedTimeWrittenOut$ = ETWORtn$
HaltAndDisplay% = 0: GTHeaderCopy$ = "": Instructions$ = "": xPos% = 0: yPos% = 0: HighlightedOption% = 0
GTHours% = 0: GTMinutes% = 0: GTSeconds% = 0: SomeKey% = 0: TimerStarted% = 0: GTClock$ = ""
FirstTime% = 0: Increment% = 0: TimeElapsed% = 0: UserCommand$ = "": MaxOption% = 0: GTRtn$ = ""
HaltAndDisplay% = TRUE%: xPos% = 13: yPos% = 25: HighlightedOption% = 1
Increment% = 1: TimerStarted% = FALSE%: MaxOption% = 3
IF HaltAndDisplay%
= TRUE%
THEN GTHeaderCopy$ = GTHeader$
LOCATE 6, 1:
PRINT LongCenter
(GTHeaderCopy$
, 50, FALSE%
) LOCATE 7, Center
(GTHeaderCopy$
) COLOR 12, 1: Instructions$
= "Use the arrow keys to select the time. Push [ESC] to reset. Push " Instructions$
= Instructions$
+ CHR$(34) + "X" + CHR$(34) + " to exit to the system. Push [ENTER] when you have selected the desired time" LOCATE 44, 1:
PRINT LongCenter$
(Instructions$
, 60, FALSE%
)
IF HighlightedOption%
= 1 THEN IF GTHours%
+ 1 >= 1 AND GTHours%
+ 1 < 13 THEN
IF HighlightedOption%
= 2 THEN IF GTMinutes%
+ 1 >= 0 AND GTMinutes%
+ 1 <= 59 THEN
IF HighlightedOption%
= 3 THEN IF GTSeconds%
+ 1 >= 0 AND GTSeconds%
+ 1 <= 59 THEN
IF GTHours%
- 1 >= 0 AND GTHours%
- 1 <= 11 THEN IF GTHours%
+ 1 >= 0 AND GTHours%
+ 1 <= 11 OR GTHours%
+ 1 = 24 THEN
GTClock$ = ClockString$(GTHours%, GTMinutes%, GTSeconds%)
HaltAndDisplay% = FALSE%
IF SomeKey%
= UpKeyHit%
OR SomeKey%
= DownKeyHit%
THEN IF TimerStarted%
= FALSE%
THEN TimerStarted% = TRUE%
FirstTime% = 0
Increment% = 1
TimeElapsed% = 0
TimerStarted% = FALSE%
IF HighlightedOption%
= 2 OR HighlightedOption%
= 3 THEN Increment%
= 3
IF HighlightedOption%
= 1 THEN GTHours% = GTHours% - Increment%
IF GTHours%
< 0 THEN GTHours%
= 23 GTMinutes% = GTMinutes% - Increment%
IF GTMinutes%
< 0 THEN GTMinutes%
= 59 GTSeconds% = GTSeconds% - Increment%
IF GTSeconds%
< 0 THEN GTSeconds%
= 59 HaltAndDisplay% = TRUE
IF HighlightedOption%
= 1 THEN GTHours% = GTHours% + Increment%
IF GTHours%
> 23 THEN GTHours%
= 0 GTMinutes% = GTMinutes% + Increment%
IF GTMinutes%
> 59 THEN GTMinutes%
= 0 GTSeconds% = GTSeconds% + Increment%
IF GTSeconds%
> 59 THEN GTSeconds%
= 0 HaltAndDisplay% = TRUE
HighlightedOption% = HighlightedOption% - 1
IF HighlightedOption%
= 0 THEN HighlightedOption%
= MaxOption%
HaltAndDisplay% = TRUE
HighlightedOption% = HighlightedOption% + 1
IF HighlightedOption%
> MaxOption%
THEN HighlightedOption%
= 1 HaltAndDisplay% = TRUE
GTRtn$ = MakeFormattedTIME$(GTHours%, GTMinutes%, GTSeconds%)
HaltAndDisplay% = TRUE%
GetTime$ = GTRtn$
FUNCTION MakeFormattedTIME$
(MFHours%
, MFMinutes%
, MFSeconds%
) MFTRtn$ = ""
IF MFHours%
< 10 THEN MFTRtn$
= "0" MFTRtn$ = MFTRtn$ + S$(MFHours%) + ":"
IF MFMinutes%
< 10 THEN MFTRtn$
= MFTRtn$
+ "0" MFTRtn$ = MFTRtn$ + S$(MFMinutes%) + ":"
IF MFSeconds%
< 10 THEN MFTRtn$
= MFTRtn$
+ "0" MFTRtn$ = MFTRtn$ + S$(MFSeconds%)
MakeFormattedTIME$ = MFTRtn$
FUNCTION LongCenter$
(Text$
, CutHere%
, BlankLineBetween%
) PartString$ = "": Spaces$ = "": CutString$ = "": LCRtn$ = "": LastSpaces$ = ""
NumLastSpaces% = 0
CutHere% = CutHere% + 1
CutHere% = CutHere% - 1
Cutting$
= MID$(Text$
, CutHere%
, 1) PartString$
= MID$(Text$
, 1, CutHere%
) Text$
= MID$(Text$
, CutHere%
+ 1, LEN(Text$
)) Spaces$
= STRING$(Center
(PartString$
), " ") CutString$ = Spaces$ + PartString$ + Spaces$
LCRtn$ = LCRtn$ + CutString$
IF BlankLineBetween%
= TRUE%
THEN LCRtn$
= LCRtn$
+ STRING$(80, " ") NumLastSpaces% = Center(Text$)
LastSpaces$
= STRING$(NumLastSpaces%
, " ") LCRtn$ = LCRtn$ + LastSpaces$ + Text$
LongCenter$ = LCRtn$
FUNCTION DaysPassedJanFromMonthDayYear%
(Month9%
, Day9%
, Years9%
) DPJFMDYRtn% = 0: LeapYear% = 0
DPJFMDYRtn% = Day9%
DPJFMDYRtn% = 31 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + 31 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + 31 + 30 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + Day9%
DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + Day9%
DaysPassedJanFromMonthDayYear = DPJFMDYRtn%
YearNow% = 0: DayNow% = 0: HourNow% = 0: MinuteNow% = 0: SecondNow% = 0: MonthNow% = 0
HLSTargetDateAndTime$ = "": Instructions$ = "": DayNowCopy% = 0: HLSTargetYear% = 0: HLSTargetDay% = 0
HLSTargetHour% = 0: HLSTargetMinute% = 0: HLSTargetSecond% = 0: HLSFinalYear% = 0: HLSFinalDay% = 0
HLSFinalHour% = 0: HLSFinalMinute% = 0: HLSFinalSecond% = 0: SecondNowCopy% = 0: MinuteNowCopy% = 0: HourNowCopy% = 0
DayNowCopy% = 0: YearNowCopy% = 0: HLSTargetMonth% = 0: HLSTargetDayCopy% = 0
DayNowCopy% = DayNow%
DayNow% = DaysPassedJanFromMonthDayYear(MonthNow%, DayNow%, YearNow%)
YearNowCopy% = YearNow%
HourNowCopy% = HourNow%
MinuteNowCopy% = MinuteNow%
SecondNowCopy% = SecondNow%
Instructions$ = "Select A Target Date and Time Before " + WrittenOutDate$(MonthNow%, DayNowCopy%, YearNow%)
Instructions$ = Instructions$ + " at " + ClockString$(HourNow%, MinuteNow%, SecondNow%)
HLSTargetDateAndTime$ = GetDateAndTime$(Instructions$)
whatTheHellString$
= MID$(HLSTargetDateAndTime$
, 6, 3) whatTheHellInteger%
= VAL(whatTheHellString$
) HLSTargetYear%
= VAL(LEFT$(HLSTargetDateAndTime$
, 4)) HLSTargetDay%
= VAL(MID$(HLSTargetDateAndTime$
, 6, 3)) HLSTargetHour%
= VAL(MID$(HLSTargetDateAndTime$
, 10, 2)) HLSTargetMinute%
= VAL(MID$(HLSTargetDateAndTime$
, 13, 2)) HLSTargetSecond%
= VAL(RIGHT$(HLSTargetDateAndTime$
, 2)) HLSTargetMonth% = MonthOrDayFromDaysPassedJan(HLSTargetDay%, 1, HLSTargetYear%)
HLSTargetDayCopy% = MonthOrDayFromDaysPassedJan(HLSTargetDay%, 2, HLSTargetYear%)
HLSFinalSecond% = SecondNow% - HLSTargetSecond%
HLSFinalSecond% = HLSFinalSecond% + 60
MinuteNow% = MinuteNow% - 1
HLSFinalMinute% = MinuteNow% - HLSTargetMinute%
HLSFinalMinute% = HLSFinalMinute% + 60
HourNow% = HourNow% - 1
HLSFinalHour% = HourNow% - HLSTargetHour%
HLSFinalHour% = HLSFinalHour% + 24
DayNow% = DayNow% - 1
HLSFinalDay% = DayNow% - whatTheHellInteger%
HLSFinalDay% = HLSFinalDay% + 365
YearNow% = YearNow% - 1
HLSFinalYear% = YearNow% - HLSTargetYear%
a$ = "": a$ = "The selected date and time is after "
a$ = a$ + WrittenOutDate$(MonthNow%, DayNowCopy%, YearNowCopy%)
a$ = a$ + " at " + ClockString$(HourNowCopy%, MinuteNowCopy%, SecondNowCopy%)
PRINT LongCenter$
(a$
, 50, TRUE%
) a$ = "": a$ = WrittenOutDate$(HLSTargetMonth%, HLSTargetDayCopy%, HLSTargetYear%)
a$ = a$ + " at " + ClockString$(HLSTargetHour%, HLSTargetMinute%, HLSTargetSecond%)
a$ = a$ + " occurred "
a$ = a$ + ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(HLSFinalYear%, HLSFinalDay%, HLSFinalHour%, HLSFinalMinute%, HLSFinalSecond%))
a$ = a$ + " ago"
PRINT LongCenter
(a$
, 50, TRUE%
) a$
= "Hit any key":
LOCATE 48, Center
(a$
):
PRINT a$: ll$
= P$
SUB WhatDateAfterElapsedTime
TimePassed$ = "": YearsToday% = 0: MonthToday% = 0: DaysToday% = 0: DaysTodayAfterJan0% = 0: HoursToday% = 0: MinutesToday% = 0
SecondsToday% = 0: YearsPassed% = 0: DaysPassed% = 0: HoursPassed% = 0: MinutesPassed% = 0: SecondsPassed% = 0
ResultingYears% = 0: ResultingDaysPassedJan% = 0: ResultingDays% = 0: ResultingHours% = 0: ResultingMinutes% = 0
ResultingSeconds% = 0: ResultingDateMonth% = 0: ResultingDateDay% = 0: ResultingDateYear% = 0: ResultingTimeHour% = 0
ResultingTimeMinutes% = 0: ResultingTimeSeconds% = 0: AnswerString$ = ""
DaysTodayAfterJan0% = DaysPassedJanFromMonthDayYear(MonthToday%, DaysToday%, YearsToday%)
TimePassed$ = GetElapsedTime$("Find the date after how much time has passed?")
YearsPassed%
= VAL(LEFT$(TimePassed$
, 4)) DaysPassed%
= VAL(MID$(TimePassed$
, 6, 3)) HoursPassed%
= VAL(MID$(TimePassed$
, 10, 2)) MinutesPassed%
= VAL(MID$(TimePassed$
, 13, 2))
ResultingSeconds% = SecondsToday% + SecondsPassed%
IF ResultingSeconds%
>= 60 THEN ResultingSeconds% = ResultingSeconds% - 60
MinutesPassed% = MinutesPassed% + 1
ResultingMinutes% = MinutesToday% + MinutesPassed%
IF ResultingMinutes%
>= 60 THEN ResultingMinutes% = ResultingMinutes% - 60
HoursPassed% = HoursPassed% + 1
ResultingHours% = HoursToday% + HoursPassed%
ResultingHours% = ResultingHours% - 24
DaysPassed% = DaysPassed% + 1
ResultingDays% = DaysTodayAfterJan0% + DaysPassed%
ResultingDays% = ResultingDays% - 365
YearsPassed% = YearsPassed% + 1
ResultingYears% = YearsToday% + YearsPassed%
ResultingDateYear% = ResultingYears%
ResultingDateMonth% = MonthOrDayFromDaysPassedJan(ResultingDays%, 1, ResultingDateYear%)
ResultingDateDay% = MonthOrDayFromDaysPassedJan(ResultingDays%, 2, ResultingDateYear%)
ResultingTimeHour% = ResultingHours%
ResultingTimeMinutes% = ResultingMinutes%
ResultingTimeSeconds% = ResultingSeconds%
AnswerString$ = ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(YearsPassed%, DaysPassed%, HoursPassed%, MinutesPassed%, SecondsPassed%))
AnswerString$ = AnswerString$ + " after now is "
AnswerString$ = AnswerString$ + WrittenOutDate$(ResultingDateMonth%, ResultingDateDay%, ResultingDateYear%)
AnswerString$ = AnswerString$ + " at " + ClockString$(ResultingTimeHour%, ResultingTimeMinutes%, ResultingTimeSeconds%)
PRINT LongCenter$
(AnswerString$
, 45, TRUE%
) a$
= "": a$
= "Hit any key":
LOCATE 48, Center
(a$
):
PRINT a$: ll$
= P$
Years1% = 0: Years2% = 0: AddedYears% = 0: Days1% = 0: Days2% = 0: AddedDays% = 0: Hours1% = 0
Hours2% = 0: AddedHours% = 0: Minutes1% = 0: Minutes2% = 0: AddedMinutes% = 0: Seconds1% = 0
Seconds2% = 0: AddedSeconds% = 0: et1$ = "": et2$ = "": Prompt2$ = "": AnswerString$ = "": AT$ = ""
et1$ = GetElapsedTime$("Select the fire time")
Prompt2$ = "Select the amount of time to add to " + ElapsedTimeWrittenOut$(et1$)
et2$ = GetElapsedTime$(Prompt2$)
AddedSeconds% = Seconds1% + Seconds2%
AddedSeconds% = AddedSeconds% - 60
Minutes1% = Minutes1% + 1
AddedMinutes% = Minutes1% + Minutes2%
AddedMinutes% = AddedMinutes% - 60
Hours1% = Hours1% + 1
AddedHours% = Hours1% + Hours2%
AddedHours% = AddedHours% - 24
Days1% = Days1% + 1
AddedDays% = Days1% + Days2%
AddedDays% = AddedDays% - 365
Years1% = Years1% + 1
AddedYears% = Years1% + Years2%
AnswerString$ = ElapsedTimeWrittenOut$(et1$) + " added with " + ElapsedTimeWrittenOut$(et2$)
ATShort$ = MakeElapsedTimeShort$(AddedYears%, AddedDays%, AddedHours%, AddedMinutes%, AddedSeconds%)
AT$ = ElapsedTimeWrittenOut$(ATShort$)
AnswerString$ = AnswerString$ + " equals " + AT$
PRINT LongCenter$
(AnswerString$
, 50, TRUE%
) ll$ = P$
Et1$ = "": Et2$ = "": Prompt1$ = "": Prompt2$ = "": Years1% = 0: Years2% = 0: SubtractedYears% = 0: Days1% = 0: Days2% = 0
SubtractedDays% = 0: Hours1% = 0: Hours2% = 0: SubtractedHours% = 0: Minutes1% = 0: Minutes2% = 0: SubtractedMinutes% = 0
Seconds1% = 0: Seconds2% = 0: SubtractedSeconds% = 0: BT% = 0: FirstYears% = 0: SecondYears% = 0: FirstDays% = 0: SecondDays% = 0
FirstHours% = 0: SecondHours% = 0: FirstMinutes% = 0: SecondMinutes% = 0: FirstSeconds% = 0: SecondSeconds% = 0: Result$ = ""
FTWO$ = "": STWO$ = "": SubTWO$ = ""
Prompt1$ = "Select one of the 2 times"
Et1$ = GetElapsedTime$(Prompt1$)
Prompt2$ = "Select the second time -- The smaller time will be subtracted from the larger"
Et2$ = GetElapsedTime$(Prompt2$)
BT% = 1
BT% = 2
ELSEIF Years1%
= Years2%
AND Days1%
= Days2%
AND Hours1%
= Hours2%
AND Minutes1%
< Minutes2%
THEN BT%
= 2 ELSEIF Years1%
= Years2%
AND Days1%
= Days2%
AND Hours1%
= Hours2%
AND Minutes1%
= Minutes1%
AND Seconds1%
< Seconds2%
THEN BT%
= 2
' first - second
FirstYears% = Years1%: SecondYears% = Years2%
FirstDays% = Days1%: SecondDays% = Days2%
FirstHours% = Hours1%: SecondHours% = Hours2%
FirstMinutes% = Minutes1%: SecondMinutes% = Minutes2%
FirstSeconds% = Seconds1%: SecondSeconds% = Seconds2%
FirstYears% = Years2%: SecondYears% = Years1%
FirstDays% = Days2%: SecondDays% = Days1%
FirstHours% = Hours2%: SecondHours% = Hours1%
FirstMinutes% = Minutes2%: SecondMinutes% = Minutes1%
FirstSeconds% = Seconds2%: SecondSeconds% = Seconds1%
SubtractedSeconds% = FirstSeconds% - SecondSeconds%
IF SubtractedSeconds%
< 0 THEN SubtractedSeconds% = SubtractedSeconds% + 60
FirstMinutes% = FirstMinutes% - 1
SubtractedMinutes% = FirstMinutes% - SecondMinutes%
IF SubtractedMinutes%
< 0 THEN SubtractedMinutes% = SubtractedMinutes% + 60
FirstHours% = FirstHours% - 1
SubtractedHours% = FirstHours% - SecondHours%
SubtractedHours% = SubtractedHours% + 24
FirstDays% = FirstDays% - 1
SubtractedDays% = FirstDays% - SecondDays%
SubtractedDays% = SubtractedDays% + 365
FirstYears% = FirstYears% - 1
SubtractedYears% = FirstYears% - SecondYears%
PRINT "SubtractedYears%: " + S$
(SubtractedYears%
) PRINT "SubtractedDays%: " + S$
(SubtractedDays%
) PRINT "SubtractedHours%: " + S$
(SubtractedHours%
) PRINT "SubtractedMinutes%: " + S$
(SubtractedMinutes%
) PRINT "SubtractedSeconds%: " + S$
(SubtractedSeconds%
) ll$ = P$
FTWO$ = ElapsedTimeWrittenOut$(Et1$)
STWO$ = ElapsedTimeWrittenOut$(Et2$)
SubTWO$ = ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(SubtractedYears%, SubtractedDays%, SubtractedHours%, SubtractedMinutes%, SubtractedSeconds%))
Result$ = FTWO$ + " minus " + STWO$ + " equals " + SubTWO$
ll$ = P$
Prompt$ = "": Et$ = "": Years% = 0: Days% = 0: Hours% = 0: Minutes% = 0: Seconds% = 0: ETWO$ = "": x = 0
Constant! = 0.0: ProductYears% = 0: ProductDays% = 0: ProductHours% = 0: ProductMinutes% = 0: ProductSeconds% = 0
TMin% = 0: THr% = 0: Tsec% = 0: Tday% = 0: Tyr% = 0: Ans$ = ""
Prompt$ = "Select a time to multiply"
Et$ = GetElapsedTime$(Prompt$)
ETWO$ = ElapsedTimeWrittenOut$(Et$)
x = Center("by what ")
ProductSeconds% = RoundOff(Seconds% * Constant! / 100) * 100
ProductSeconds% = ProductSeconds% - 60
TMin% = TMin% + 1
ProductMinutes% = RoundOff(Minutes% * Constant! / 100) * 100 + TMin%
ProductMinutes% = ProductMinutes% - 60
THr% = THr% + 1
ProductHours% = RoundOff(Hours% * Constant! / 100) * 100 + THr%
ProductHours% = ProductHours% - 24
Tday% = Tday% + 1
ProductDays% = RoundOff(Days% * Constant! / 100) * 100 + Tday%
ProductDays% = ProductDays% - 365
Tyr% = Tyr% + 1
ProductYears% = RoundOff(Years% * Constant! / 100) * 100 + Tyr%
LOCATE 20, Center
(ElapsedTimeWrittenOut$
(Et$
)):
PRINT ElapsedTimeWrittenOut$
(Et$
) Ans$
= "multiplied by " + S$
(Constant!
) + " equals":
LOCATE 22, Center
(Ans$
):
PRINT Ans$
PRINT LongCenter
(ElapsedTimeWrittenOut$
(MakeElapsedTimeShort$
(ProductYears%
, ProductDays%
, ProductHours%
, ProductMinutes%
, ProductSeconds%
)), 40, TRUE
) ll$ = P$
DIM Rtn!
, DifferentNumber!
, Decimal!: Rtn
= 0.0: DifferentNumber
= 0.0: Decimal
= 0.0 Decimal
= INT(Number
* 1000) - (INT(Number
* 100) * 10) DifferentNumber!
= INT(Number!
* 100) DifferentNumber! = DifferentNumber! + 1
DifferentNumber! = DifferentNumber!
Rtn = DifferentNumber! / 100
RoundOff = Rtn!
DIM minOption
, maxOption
, haltAndDisplay
, xPos
, yPos
, highlightedOption
AS INTEGER KeyThatWasHit% = 0: TimerStarted% = FALSE%: FirstTime% = 0: Increment% = 1: RecentTime% = 0: TimeDifference% = 0
highlightedOption = 4: haltAndDisplay = TRUE
minOption = 4: maxOption = 8
titleCopy$ = title$
a$ = LongCenter(titleCopy$, 60, FALSE%)
Instructions$ = ""
Instructions$ = "Use the arrow keys to select the desired elapsed time - Push [ENTER] to accept - Push "
Instructions$
= Instructions$
+ "Push [ESC] to reset - Push " + CHR$(34) + "X" + CHR$(34) + " to exit to the system" PRINT LongCenter$
(Instructions$
, 50, FALSE%
)
xPos = xPos + 16
'Years
'Days
a$ = "": a$ = ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(Years1, Days1, Hours1, Minutes1, Seconds1))
haltAndDisplay = FALSE
IF SomeKey%
= UpKeyHit%
OR SomeKey%
= DownKeyHit%
THEN IF TimerStarted%
= FALSE%
THEN TimerStarted% = TRUE%
FirstTime% = 0
Increment% = 1
TimeElapsed% = 0
TimerStarted% = FALSE%
IF highlightedOption
= 4 THEN Increment%
= 5 IF highlightedOption
= 5 THEN Increment%
= 3 IF highlightedOption
= 7 THEN Increment%
= 2 IF highlightedOption
= 8 THEN incrment%
= 2 IF highlightedOption
= 4 THEN Increment%
= 15 IF highlightedOption
= 5 THEN Increment%
= 10 IF highlightedOption
= 7 THEN Increment%
= 5 IF highlightedOption
= 8 THEN Increment%
= 5 IF highlightedOption
= 4 THEN Increment%
= 40 IF highlightedOption
= 5 THEN Increment%
= 15
Years1 = Years1 - Increment%
IF Years1
<= -1 THEN Years1
= 9999 Days1 = Days1 - Increment%
IF Days1
<= -1 THEN Days1
= 364 Hours1 = Hours1 - 1
IF Hours1
= -1 THEN Hours1
= 23 Minutes1 = Minutes1 - Increment%
IF Minutes1
<= -1 THEN Minutes1
= 59 Seconds1 = Seconds1 - Increment%
IF Seconds1
<= -1 THEN Seconds1
= 59 haltAndDisplay = TRUE
Years1 = Years1 + Increment%
IF Years1
>= 10000 THEN Years1
= 0 Days1 = Days1 + Increment%
IF Days1
>= 365 THEN Days1
= 0 Hours1 = Hours1 + 1
IF Hours1
= 24 THEN Hours1
= 0 Minutes1 = Minutes1 + Increment%
IF Minutes1
>= 60 THEN Minutes1
= 0 Seconds1 = Seconds1 + Increment%
IF Seconds1
>= 60 THEN Seconds1
= 0 haltAndDisplay = TRUE
highlightedOption = highlightedOption + 1
IF highlightedOption
> maxOption
THEN highlightedOption
= minOption
haltAndDisplay = TRUE
highlightedOption = highlightedOption - 1
IF highlightedOption
< minOption
THEN highlightedOption
= maxOption
haltAndDisplay = TRUE
Rtn$ = MakeElapsedTimeShort$(Years1, Days1, Hours1, Minutes1, Seconds1)
montH = 1: daY = 1: year = 2022
Years1 = 0: Days1 = 0: Hours1 = 0: Minutes1 = 0: Seconds1 = 0
Years2 = 0: Days2 = 0: Hours2 = 0: Minutes2 = 0: Seconds2 = 0
haltAndDisplay = TRUE
GetElapsedTime$ = Rtn$
FUNCTION MonthOrDayFromDaysPassedJan%
(Days27%
, Month1Day2%
, Year27%
) MODFDPJRtn% = 0: Month27% = 0: Leap% = 0
Month27% = 1
Days27% = Days27%
CASE 32 TO 59 + Leap%
'February Month27% = 2
Days27% = Days27% - 31
CASE 60 + Leap%
TO 90 + Leap%
'March Month27% = 3
Days27% = Days27% - 59 - Leap%
CASE 91 + Leap%
TO 120 + Leap%
'april Month27% = 4
Days27% = Days27% - 90 - Leap%
CASE 121 + Leap%
TO 151 + Leap%
'may Month27% = 5
Days27% = Days27% - 120 - Leap%
CASE 152 + Leap%
TO 181 + Leap%
Month27% = 6
Days27% = Days27% - 150 - Leap%
CASE 182 + Leap%
TO 212 + Leap%
Month27% = 7
Days27% = Days27% - 180 - Leap%
CASE 213 + Leap%
TO 243 + Leap%
Month27% = 8
Days27% = Days27% - 212 - Leap%
CASE 244 + Leap%
TO 273 + Leap%
Month27% = 9
Days27% = Days27% - 243 - Leap%
CASE 274 + Leap%
TO 304 + Leap%
Month27% = 10
Days27% = Days27% - 273 - Leap%
CASE 305 + Leap%
TO 334 + Leap%
Month27% = 11
Days27% = Days27% - 304 - Leap%
CASE 335 + Leap%
TO 365 + Leap%
Month27% = 12
Days27% = Days27% - 334 - Leap%
MODFDPJRtn% = Month27%
MODFDPJRtn% = Days27%
MonthOrDayFromDaysPassedJan = MODFDPJRtn%
MWRtn$ = ""
CASE 0 ' for the top value of the dial MWRtn$ = "December"
MWRtn$ = "January"
MWRtn$ = "February"
MWRtn$ = "March"
MWRtn$ = "April"
MWRtn$ = "May"
MWRtn$ = "June"
MWRtn$ = "July"
MWRtn$ = "August"
MWRtn$ = "September"
MWRtn$ = "October"
MWRtn$ = "November"
MWRtn$ = "December"
CASE 13 'for the bottom value of the dial MWRtn$ = "January"
MonthWord$ = MWRtn$
SRtn$ = ""
IF DaySuffix%
= 1 OR DaySuffix%
= 21 OR DaySuffix%
= 31 THEN SRtn$ = "st"
Suffix$ = SRtn$
FUNCTION WrittenDate1Clock2Time3$
(AllFive$
, Which%
) WD1C2T3Rtn$ = "": Years8% = 0: Days8% = 0: Hours8% = 0: Minutes8% = 0: Seconds8% = 0: Month8% = 0
AmPm8$ = "": LftNum8% = 0: RtNum8% = 0: LpYr% = 0
Years8%
= VAL(MID$(AllFive$
, 1, 4)) Hours8%
= VAL(MID$(AllFive$
, 10, 2)) Minutes8%
= VAL(MID$(AllFive$
, 13, 2)) Seconds8%
= VAL(MID$(AllFive$
, 16, 2)) Month8% = MonthOrDayFromDaysPassedJan(Days8% - LpYr%, 1, Years8%)
Days8% = MonthOrDayFromDaysPassedJan(Days8% - LpYr%, 2, Years8%)
WD1C2T3Rtn$ = MonthWord$(Month8%)
WD1C2T3Rtn$ = WD1C2T3Rtn$ + " " + S$(Days8%)
WD1C2T3Rtn$ = WD1C2T3Rtn$ + Suffix$(Days8%) + ", " + S$(Years8%)
WD1C2T3Rtn$ = "12"
AmPm8$ = "AM"
WD1C2T3Rtn$ = S$(Hours8%)
AmPm8$ = "AM"
WD1C2T3Rtn$ = "12"
AmPm8$ = "PM"
WD1C2T3Rtn$ = S$(Hours8% - 12)
AmPm8$ = "PM"
WD1C2T3Rtn$ = WD1C2T3Rtn$ + ":" + S$(Minutes8%) + " " + AmPm8$ + " and " + S$(Seconds8%)
IF Seconds8%
<> 1 THEN WD1C2T3Rtn$
= WD1C2T3Rtn$
+ "s" LftNum8%
= INT(Years8%
/ 1000) WD1C2T3Rtn$ = S$(LftNum8%) + ","
RtNum8% = Years8% - (LftNum8% * 1000)
WD1C2T3Rtn$ = WD1C2T3Rtn$ + "00"
WD1C2T3Rtn$ = WD1C2T3Rtn$ + "0"
WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(RtNum8%)
WD1C2T3Rtn$ = S$(Years8%)
WD1C2T3Rtn$ = WD1C2T3Rtn$ + " Year"
IF Years%
<> 1 THEN WD1C2T3Rtn$
= WD1C2T3Rtn$
+ "s" IF Days8%
<> 0 AND (Hours3%
<> 0 OR Minutes8%
<> 0 OR Seconds8%
<> 0) THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(Days8%) + " Day"
IF Days8%
<> 1 THEN WD1C2T3Rtn$
= WD1C2T3Rtn$
+ "s" IF Hours8%
<> 0 AND (Minutes8%
<> 0 OR Seconds8%
<> 0) THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(Hours8%) + " hour"
IF Hours8%
<> 1 THEN WD1C2T3Rtn$
= WD1C2T3Rtn$
+ "s" WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(Minutes8%) + " minute"
IF Minutes8%
<> 1 THEN WD1C2T3Rtn$
= WD1C2T3Rtn$
+ "s" IF Seconds8%
<> 0 THEN WD1C2T3Rtn$
= WD1C2T3Rtn$
+ " and " WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(Seconds8%) + " second"
IF Seconds8%
<> 1 THEN WD1C2T3Rtn$
= WD1C2T3Rtn$
+ "s" IF Years8%
= 0 AND Days8%
= 0 AND Hours8%
= 0 AND Minutes8%
= 0 AND Seconds8%
= 0 THEN WD1C2T3Rtn$
= "Nothing" WrittenDate1Clock2Time3$ = WD1C2T3Rtn$
HaltAndDisplay% = 0: HighlightedOption% = 0: yPos% = 0: UserCommand$ = "": A$ = ""
xPos% = 0: MaxOption% = 0: SelectedAnOption% = 0
HaltAndDisplay% = TRUE%: HighlightedOption% = 1: yPos% = 13: MaxOption% = 7: SelectedAnOption% = FALSE%
HighlightedOption% = 1
HaltAndDisplay% = TRUE%
yPos = 14
IF HaltAndDisplay%
= TRUE%
THEN A$ = "Time Calculator Menu": xPos% = Center(A$)
PRINT "---- ---------- ----"
A$ = "": A$ = "1.) Find How Long From Now"
LOCATE yPos%
+ 3, Center
(A$
):
IF HighlightedOption%
= 1 THEN A$ = "": A$ = "Until A Selected Time"
LOCATE yPos%
+ 4, Center
(A$
):
IF HighlightedOption%
= 1 THEN
A$ = "": A$ = "2.) Find How Long It Has Been Since"
LOCATE yPos%
+ 6, Center
(A$
):
IF HighlightedOption%
= 2 THEN A$ = "": A$ = "A Selected Time Has Passed"
LOCATE yPos%
+ 7, Center
(A$
):
IF HighlightedOption%
= 2 THEN
A$ = "": A$ = "3.) Find The Date And Time It Will Be After"
LOCATE yPos%
+ 9, Center
(A$
):
IF HighlightedOption%
= 3 THEN A$ = "": A$ = "A Selected Amount Of Time Has Passed"
LOCATE yPos%
+ 10, Center
(A$
):
IF HighlightedOption%
= 3 THEN
A$ = "": A$ = "4.) Add Two Elapsed Times"
LOCATE yPos%
+ 12, Center
(A$
):
IF HighlightedOption%
= 4 THEN
A$ = "": A$ = "5.) Subtract One Elapsed Time From Another One"
LOCATE yPos%
+ 14, Center
(A$
):
IF HighlightedOption%
= 5 THEN
A$ = "": A$ = "6.) Multiply An Elapsed Time By A Constant"
LOCATE yPos%
+ 16, Center
(A$
):
IF HighlightedOption%
= 6 THEN
A$ = "": A$ = "7.) Exit"
LOCATE 45, Center
(A$
):
IF HighlightedOption%
= MaxOption%
THEN
HaltAndDisplay% = FALSE%
CASE UpArrowKey$
, LeftArrowKey$
HighlightedOption% = HighlightedOption% - 1
IF HighlightedOption%
= 0 THEN HighlightedOption%
= MaxOption%
HaltAndDisplay% = TRUE%
CASE DownArrowKey$
, RightArrowKey$
HighlightedOption% = HighlightedOption% + 1
IF HighlightedOption%
> MaxOption%
THEN HighlightedOption%
= 1 HaltAndDisplay% = TRUE%
SelectedAnOption% = TRUE%
CASE "1", "2", "3", "4", "5", "6" HighlightedOption%
= VAL(UserCommand$
) SelectedAnOption% = TRUE%
IF SelectedAnOption%
= TRUE
THEN SelectedAnOption% = FALSE%
HaltAndDisplay% = TRUE%
SelectedAnOption% = FALSE%
HaltAndDisplay% = TRUE%
CALL WhatDateAfterElapsedTime
SelectedAnOption% = FALSE%
HaltAndDisplay% = TRUE%
SelectedAnOption% = FALSE%
HaltAndDisplay% = TRUE%
CALL SubtractElapsedTimes
SelectedAnOption% = FALSE%
HaltAndDisplay% = TRUE%
SelectedAnOption% = FALSE%
HaltAndDisplay% = TRUE%