Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
QB64 Discussion / Re: SEEK # or not SEEK #
« Last post by SMcNeill on April 15, 2022, 12:37:34 pm »
Open "d:/SequentialFile1" for INPUT as #52
Seek #52, Seek(1)

This won't work at all the way you have it, nor for what you're trying to use it for.   Bare with me a bit, as I try and explain these various commands.

SEEK #55, whatever --- this is a SUB which you're calling.  https://wiki.qb64.org/wiki/SEEK_(statement)   It basically is a way to telling the program to move the file pointer to whatever position you want it at.

, Seek(1) ---  this is the FUNCTION which you're calling.  https://wiki.qb64.org/wiki/SEEK  It basically is a way of your programing asking where the file pointer of some file is currently at.

So:  SEEK #52, Seek(1) is basically saying:
Move the file pointer on (filehandle 52) to wherever the file pointer on (filehandle 1) is currently positioned.

Since you don't have an OPEN whateverFile$ FOR INPUT/OUTPUT AS #1, you're going to get an error as there's no open filehandle 1.



So, that's the FIRST reason why what you're trying isn't going to work.

The second reason is due to you OPENing the file in question FOR INPUT.

SEEK (as the SUB version) will place you directly at whatever byte you want to go to -- it doesn't track record positions at all.   It's only when you OPEN FOR RANDOM, that SEEK will move from one record to the next...

INPUT/OUTPUT/BINARY -- SEEK moves to byte position
RANDOM -- SEEK moves to record position



So, the only way something like this would be somewhat valid would be if:

OPEN "d:/SequentialFile1" For Random AS #52
Seek #52, Seek(52) + 1   'move to next record

Notice how all my file handles reference the same file, and that it's an Open For Random file?

I'm thinking the above is close to what you're shooting for, but I'm not certain as the original isn't really code which can do anything except error on you.  What exactly are you trying to do with the code here, after all?

OPEN "d:/SequentialFile1" For Random AS #52
Seek #52, 1   'move to first record
Seek #52, 3   'move to third record
Seek #52, Seek(52) + 2   'move two records past the current one
22
QB64 Discussion / Re: An introduction; A note on Wiki
« Last post by bplus on April 15, 2022, 12:13:01 pm »
Welcome @dcromley

Are you talking about static for the whole sub or all the variables in it?
Was this something in earlier QB?

I know you can have Static variables in a Sub but I don't think that's what you mean.

23
QB64 Discussion / Re: SEEK # or not SEEK #
« Last post by bplus on April 15, 2022, 12:08:54 pm »
Why use seek with a sequential file, you have to worry about CR and LF chr$(13) chr$(10)... and an EOF marker too I think?

Sequential files best for variable length data.
24
QB64 Discussion / Re: _FileExists not working with wildcards
« Last post by bplus on April 15, 2022, 12:05:01 pm »
I would use a shell command to delete files with wildcards.

Really it's just one line of code? Why not that? Too easy!
25
QB64 Discussion / SEEK # or not SEEK #
« Last post by Dimster on April 15, 2022, 12:02:52 pm »
Running into a bad file name or number error message when using Seek on a sequential file and not sure why.

Open "d:/SequentialFile1" for INPUT as #52
Seek #52, Seek(1)

The above is generating the error message. I have checked the name of the file I'm trying to open, and that the file is indeed on my "d" drive, also that the same opening statement works with Input #52.

I checked the wiki and the example it provides drops the "#" . The wiki has the seek statement as SEEK 1, Seek(1) ( ie there is no "#").

I'm not sure which is the correct statement but no matter, both with or without the "#" I'm getting the error message. I have also tried to be sure the file I'm trying to access is Closed before the Opening statement.

Any idea's on what I could be doing wrong, and which to the two Seek statements is the correct one?

Thanks
26
QB64 Discussion / An introduction; A note on Wiki
« Last post by dcromley on April 15, 2022, 11:34:00 am »
This is my first post -- it is meant to be constructive -- there is so much here; so much history; a bottomless pit.
I haven't got the hang of here vs. discord vs. tapatalk.

I noticed that the Wiki for "SUB" does not have the "static" option.
I hope it is helpful to point that out.

I met a nice guy on PM.
Looking forward to more looking and participating.
27
Programs / Re: Better Bench by Ed Davis
« Last post by Aurel on April 15, 2022, 06:49:12 am »
Here is my results with qb64 1.5v on win7 32bit
28
QB64 Discussion / Re: _FileExists not working with wildcards
« Last post by hanness on April 15, 2022, 02:00:29 am »
Luke, I understand what you are saying, but in my particular use scenario, those concerns will never apply. I will ALWAYS have sufficient permission to delete those files, and it is 100% guaranteed that nothing else will remove the file.

But I do still understand and appreciate your point.
29
QB64 Discussion / Re: _FileExists not working with wildcards
« Last post by luke on April 14, 2022, 08:58:04 pm »
It's fundamentally the wrong idea to rely on _fileexists to say whether or not an IO operation will succeed. The file might exist but you have insufficient permission to open/delete it, another program might remove the file between your program checking and using the file, there may be a network error (if the file is from a network share). A more robust solution is to simply catch the error and respond accordingly:
Code: [Select]
'At the top of the program
On Error Goto general_error
Dim Shared Error_happened As Long

'Main Program

End
general_error:
Print "Fatal error"; err; "at line"; _errorline
end

io_error:
Error_happened = err
Resume Next

Sub delete_files(names$)
Error_happened = 0
On Error Goto io_error
Kill names$
On Error Goto general_error
If Error_happened then
  'Ignore or inform user, depending on use case
End If
End Sub
30
QB64 Discussion / Time Calculator
« Last post by Jaze on April 14, 2022, 08:05:31 pm »
Code: QB64: [Select]
  1. _TITLE "Time Calculator" ' I do wonder if I should start planning before I begin to code...
  2. 'Author: Jaze James McAskill (mcaskilljaze@gmail.com)
  3. 'License: Freeware if anyone can remember what that is.
  4. '            All I ask is that if you copy part or all
  5. '           of this code you keep my name on it
  6.  
  7. CONST TRUE% = 1
  8. CONST FALSE% = -1
  9. CONST AM% = -1
  10. CONST PM% = 1
  11.  
  12.  
  13. WIDTH 80, 50
  14.  
  15.  
  16. DIM SHARED LeftArrowKey$: LeftArrowKey$ = CHR$(0) + "K"
  17. DIM SHARED RightArrowKey$: RightArrowKey$ = CHR$(0) + "M"
  18. DIM SHARED UpArrowKey$: UpArrowKey$ = CHR$(0) + "H"
  19. DIM SHARED DownArrowKey$: DownArrowKey$ = CHR$(0) + "P"
  20. CONST UpKeyHit% = 18432
  21. CONST DownKeyHit% = 20480
  22. CONST LeftKeyHit% = 19200
  23. CONST RightKeyHit% = 19712
  24.  
  25.  
  26. LOCATE 20, 1
  27.  
  28.  
  29. CALL Menu
  30.  
  31. FUNCTION GetDateAndTime$ (Header$)
  32.   HaltAndDisplay% = 0: UserCommand$ = "": HeaderCopy$ = "": Instructions$ = "": HighlightedOption% = 0
  33.   yPos% = 0: xPos% = 0: GDTMonth% = 0: GDTDay% = 0: GDTYear% = 0: O% = 0: OP$ = "": MaxOption% = 0
  34.   GDTHours% = 0: GDTMinutes% = 0: GDTSeconds% = 0: GDTRtn$ = ""
  35.   MW$ = "": SomeKey% = 0: TimerStarted% = 0: FirstTime% = 0: Increment% = 0: TimeElapsed% = 0
  36.  
  37.   HaltAndDisplay% = TRUE: yPos% = 15: xPos% = 17: HighlightedOption% = 1: MaxOption% = 6
  38.   GDTMonth% = VAL(LEFT$(DATE$, 2)): GDTDay% = VAL(MID$(DATE$, 4, 2)): GDTYear% = VAL(RIGHT$(DATE$, 4))
  39.   GDTHours% = VAL(LEFT$(TIME$, 2)): GDTMinutes% = VAL(MID$(TIME$, 4, 2)): GDTSeconds% = VAL(RIGHT$(TIME$, 2))
  40.   TimerStarted% = FALSE%: Increment% = 1
  41.   DO
  42.     UserCommand$ = INKEY$
  43.     IF HaltAndDisplay% = TRUE% THEN
  44.       xPos% = 17: yPos% = 15
  45.       HeaderCopy$ = Header$
  46.       COLOR 14, 1: CLS
  47.       COLOR 15
  48.       IF LEN(Header$) >= 50 THEN
  49.         LOCATE 3, 1: PRINT LongCenter(HeaderCopy$, 50, FALSE%)
  50.       ELSE LOCATE 3, Center(HeaderCopy$): PRINT HeaderCopy$: END IF
  51.       COLOR 12, 1: Instructions$ = "Use the arrow keys to select the date and time - Push "
  52.       Instructions$ = Instructions$ + CHR$(34) + "X" + CHR$(34) + " to exit to the system - Push [ESC] to reset - Push [ENTER] to confirm"
  53.       LOCATE 46, 1: PRINT LongCenter$(Instructions$, 50, FALSE)
  54.  
  55.       LOCATE yPos% - 5, xPos%: IF HighlightedOption% = 1 THEN
  56.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Month"
  57.       MW$ = "": MW$ = MonthWord$(GDTMonth% - 1): COLOR 14, 1
  58.       LOCATE yPos% - 2, CenterBetween(MW$, xPos% - 3, xPos% + 8): PRINT MW$
  59.       MW$ = "": MW$ = MonthWord$(GDTMonth%): COLOR 10, 0
  60.       LOCATE yPos%, CenterBetween(MW$, xPos% - 3, xPos% + 8): PRINT MW$
  61.       MW$ = "": MW$ = MonthWord$(GDTMonth% + 1): COLOR 14, 1
  62.       LOCATE yPos% + 2, CenterBetween(MW$, xPos% - 3, xPos% + 8): PRINT MW$
  63.  
  64.       LOCATE yPos% - 5, xPos% + 20: IF HighlightedOption% = 2 THEN
  65.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Day"
  66.       COLOR 14, 1: O% = 0: O% = CorrectDay(GDTMonth%, GDTDay% - 1, GDTYear%)
  67.       OP$ = "": OP$ = S$(O%) + Suffix$(O%)
  68.       LOCATE yPos% - 2, CenterBetween(OP$, xPos% + 19, xPos% + 22): PRINT OP$
  69.       COLOR 10, 0: OP$ = "": O% = 0: OP$ = S$(GDTDay%) + Suffix$(GDTDay%)
  70.       LOCATE yPos%, CenterBetween(OP$, xPos% + 19, xPos% + 22): PRINT OP$
  71.       COLOR 14, 1: O% = 0: O% = CorrectDay(GDTMonth%, GDTDay% + 1, GDTYear%)
  72.       OP$ = "": OP$ = S$(O%) + Suffix$(O%)
  73.       LOCATE yPos% + 2, CenterBetween(OP$, xPos% + 19, xPos% + 22): PRINT OP$
  74.  
  75.       LOCATE yPos% - 5, xPos% + 40: IF HighlightedOption% = 3 THEN
  76.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Year"
  77.       COLOR 14, 1: O% = 0: O% = GDTYear% - 1: IF O% = -1 THEN O% = 9999
  78.       LOCATE yPos% - 2, CenterBetween(S$(O%), xPos% + 40, xPos% + 44): PRINT S$(O%)
  79.       COLOR 10, 0: LOCATE yPos%, CenterBetween(S$(GDTYear%), xPos% + 40, xPos% + 44): PRINT S$(GDTYear%)
  80.       COLOR 14, 1: O% = 0: O% = GDTYear% + 1: IF O% > 9999 THEN O% = 0
  81.       LOCATE yPos% + 2, CenterBetween(S$(O%), xPos% + 40, xPos% + 44): PRINT S$(O%)
  82.  
  83.       COLOR 10, 1: a$ = "": a$ = WrittenOutDate$(GDTMonth%, GDTDay%, GDTYear%) + " at " + ClockString$(GDTHours%, GDTMinutes%, GDTSeconds%)
  84.       LOCATE yPos% + 9, Center(a$): PRINT a$
  85.  
  86.       yPos% = yPos% + 21
  87.  
  88.       IF HighlightedOption% = 4 THEN
  89.       COLOR 10, 0: ELSE COLOR 14, 1: END IF
  90.       LOCATE yPos% - 5, xPos%: PRINT "Hours"
  91.       LOCATE yPos% - 2, xPos% + 2
  92.       COLOR 14, 1:
  93.       IF GDTHours% - 1 = -1 THEN
  94.         PRINT "11"
  95.       ELSEIF GDTHours% - 1 = 0 THEN PRINT "12"
  96.       ELSEIF GDTHours% - 1 > 0 AND GDTHours% - 1 <= 12 THEN PRINT S$(GDTHours% - 1)
  97.       ELSEIF GDTHours% - 1 >= 13 AND GDTHours% - 1 <= 23 THEN PRINT S$(GDTHours% - 1 - 12): END IF
  98.       LOCATE yPos%, xPos% + 2: COLOR 10, 0
  99.       IF GDTHours% = 0 THEN
  100.         PRINT "12"
  101.       ELSEIF GDTHours% > 0 AND GDTHours% <= 12 THEN PRINT S$(GDTHours%)
  102.       ELSEIF GDTHours% > 12 AND GDTHours% < 24 THEN PRINT S$(GDTHours% - 12): END IF
  103.       LOCATE yPos% + 2, xPos% + 2: COLOR 14, 1
  104.       IF GDTHours% + 1 >= 1 AND GDTHours% + 1 < 13 THEN
  105.         PRINT S$(GDTHours% + 1)
  106.       ELSEIF GDTHours% + 1 >= 13 AND GDTHours% + 1 <= 24 THEN PRINT S$(GDTHours% + 1 - 12): END IF
  107.  
  108.       IF HighlightedOption% = 5 THEN
  109.       COLOR 10, 0: ELSE COLOR 14, 1: END IF
  110.       LOCATE yPos% - 5, xPos% + 16: PRINT "Minutes"
  111.       LOCATE yPos% - 2, xPos% + 18: COLOR 14, 1
  112.       IF GDTMinutes% - 1 = -1 THEN
  113.         PRINT "59"
  114.       ELSEIF GDTMinutes% - 1 >= 0 AND GDTMinutes% - 1 <= 59 THEN
  115.         IF GDTMinutes% - 1 < 10 THEN PRINT "0";:
  116.         PRINT S$(GDTMinutes% - 1)
  117.       END IF
  118.       LOCATE yPos%, xPos% + 18: COLOR 10, 0: IF GDTMinutes% < 10 THEN PRINT "0";
  119.       PRINT S$(GDTMinutes%)
  120.       LOCATE yPos% + 2, xPos% + 18: COLOR 14, 1
  121.       IF GDTMinutes% + 1 >= 0 AND GDTMinutes% + 1 <= 59 THEN
  122.         IF GDTMinutes% + 1 < 10 THEN PRINT "0";
  123.         PRINT S$(GDTMinutes% + 1)
  124.       ELSEIF GDTMinutes% + 1 = 60 THEN PRINT "00"
  125.       END IF
  126.  
  127.       IF HighlightedOption% = 6 THEN
  128.       COLOR 10, 0: ELSE COLOR 14, 1: END IF
  129.       LOCATE yPos% - 5, xPos% + 32: PRINT "Seconds"
  130.       LOCATE yPos% - 2, xPos% + 36: COLOR 14, 1
  131.       IF GDTSeconds% - 1 = -1 THEN
  132.         PRINT "59"
  133.       ELSEIF GDTSeconds% - 1 >= 0 AND GDTSeconds% <= 59 THEN
  134.         PRINT S$(GDTSeconds% - 1)
  135.       END IF
  136.       LOCATE yPos%, xPos% + 36: COLOR 10, 0
  137.       PRINT S$(GDTSeconds%)
  138.       LOCATE yPos% + 2, xPos% + 36: COLOR 14, 1
  139.       IF gdtseonds% + 1 >= 0 AND GDTSeconds% + 1 <= 59 THEN
  140.         PRINT S$(GDTSeconds% + 1)
  141.       ELSEIF GDTSeconds% + 1 = 60 THEN PRINT "0": END IF
  142.  
  143.       LOCATE yPos% - 2, xPos% + 50: COLOR 14, 1
  144.       IF GDTHours% - 1 >= 0 AND GDTHours% - 1 <= 11 THEN
  145.       PRINT "AM": ELSE PRINT "PM": END IF
  146.       LOCATE yPos%, xPos% + 50: COLOR 10, 0
  147.       IF GDTHours% < 12 THEN
  148.       PRINT "AM": ELSE PRINT "PM": END IF
  149.       LOCATE yPos% + 2, xPos% + 50: COLOR 14, 1
  150.       IF GDTHours% + 1 >= 0 AND GDTHours% + 1 <= 11 OR GDTHours% + 1 = 24 THEN
  151.       PRINT "AM": ELSE: PRINT "PM": END IF
  152.  
  153.       HaltAndDisplay% = FALSE
  154.     END IF
  155.  
  156.     SomeKey% = _KEYHIT
  157.     IF SomeKey% = UpKeyHit% OR SomeKey% = DownKeyHit% THEN
  158.       IF TimerStarted% = FALSE% THEN
  159.         FirstTime% = TIMER
  160.         TimerStarted% = TRUE%
  161.       END IF
  162.     END IF
  163.     IF SomeKey% < 0 THEN
  164.       FirstTime% = 0
  165.       Increment% = 1
  166.       TimeElapsed% = 0
  167.       TimerStarted% = FALSE%
  168.     END IF
  169.     TimeElapsed% = ABS(TIMER - FirstTime%)
  170.     IF TimeElapsed% = 2 THEN
  171.       IF HighlightedOption% = 2 THEN Increment% = 2 'Day
  172.       IF HighlightedOption% = 3 THEN Increment% = 10 'Year
  173.       IF HighlightedOption% = 5 THEN Increment% = 2 'minutes
  174.       IF HighlightedOption% = 6 THEN Increment% = 2 'seconds
  175.     ELSEIF TimeElapsed% = 3 THEN
  176.       IF HighlightedOption% = 3 THEN Increment% = 25
  177.     ELSEIF TimeElapsed% = 4 THEN
  178.       IF HighlightedOption% = 3 THEN Increment% = 50
  179.     END IF
  180.  
  181.     SELECT CASE UserCommand$
  182.       CASE LeftArrowKey$
  183.         HighlightedOption% = HighlightedOption% - 1
  184.         IF HighlightedOption% = 0 THEN HighlightedOption% = MaxOption%
  185.         HaltAndDisplay% = TRUE%
  186.       CASE RightArrowKey$
  187.         HighlightedOption% = HighlightedOption% + 1
  188.         IF HighlightedOption% > MaxOption% THEN HighlightedOption% = 1
  189.         HaltAndDisplay% = TRUE%
  190.       CASE UpArrowKey$
  191.         IF HighlightedOption% = 1 THEN
  192.           GDTMonth% = GDTMonth% - Increment%
  193.           IF GDTMonth% <= 0 THEN GDTMonth% = 12
  194.           IF GDTMonth% = 4 OR GDTMonth% = 6 OR GDTMonth% = 9 OR GDTMonth% = 11 THEN
  195.             IF GDTDay% = 31 THEN GDTDay% = 30:
  196.           ELSEIF GDTMonth% = 2 THEN
  197.             IF GDTDay% > 29 AND GDTYear% MOD 4 = 0 THEN
  198.               GDTDay% = 29
  199.             ELSEIF GDTDay% >= 29 AND GDTYear% MOD 4 <> 0 THEN GDTDay% = 28
  200.             END IF
  201.           END IF
  202.         ELSEIF HighlightedOption% = 2 THEN
  203.           GDTDay% = GDTDay% - Increment%
  204.           IF GDTDay% <= 0 THEN
  205.             IF GDTMonth% = 4 OR GDTMonth% = 6 OR GDTMonth% = 9 OR GDTMonth% = 11 THEN
  206.               GDTDay% = 30
  207.             ELSEIF GDTMonth% = 2 AND GDTYear% MOD 4 = 0 THEN GDTDay% = 29
  208.             ELSEIF GDTMonth% = 2 AND GDTYear% MOD 4 <> 0 THEN GDTDay% = 28
  209.             ELSE GDTDay% = 31: END IF
  210.           END IF
  211.         ELSEIF HighlightedOption% = 3 THEN
  212.           GDTYear% = GDTYear% - Increment%
  213.           IF GDTYear% < 0 THEN GDTYear% = 9999
  214.           GDTDay% = CorrectDay%(GDTMonth%, GDTDay%, GDTYear%)
  215.         ELSEIF HighlightedOption% = 4 THEN
  216.           GDTHours% = GDTHours% - 1
  217.           IF GDTHours% < 0 THEN GDTHours% = 23
  218.         ELSEIF HighlightedOption% = 5 THEN
  219.           GDTMinutes% = GDTMinutes% - Increment%
  220.           IF GDTMinutes% < 0 THEN GDTMinutes% = 59
  221.         ELSEIF HighlightedOption% = 6 THEN
  222.           GDTSeconds% = GDTSeconds% - Increment%
  223.           IF GDTSeconds% < 0 THEN GDTSeconds% = 59
  224.         END IF
  225.         HaltAndDisplay% = TRUE%
  226.       CASE DownArrowKey$
  227.         IF HighlightedOption% = 1 THEN
  228.           GDTMonth% = GDTMonth% + Increment%
  229.           IF GDTMonth% > 12 THEN GDTMonth% = 1
  230.           GDTDay% = CorrectDay%(GDTMonth%, GDTDay%, GDTYear%)
  231.         ELSEIF HighlightedOption% = 2 THEN
  232.           GDTDay% = GDTDay% + Increment%
  233.           IF GDTDay% >= 29 THEN GDTDay% = CorrectDay(GDTMonth%, GDTDay%, GDTYear%)
  234.         ELSEIF HighlightedOption% = 3 THEN
  235.           GDTYear% = GDTYear% + Increment%
  236.           IF GDTYear% > 9999 THEN GDTYear% = 0
  237.           GDTDay% = CorrectDay%(GDTMonth%, GDTDay%, GDTYear%)
  238.         ELSEIF HighlightedOption% = 4 THEN
  239.           GDTHours% = GDTHours% + 1
  240.           IF GDTHours% = 24 THEN GDTHours% = 0
  241.         ELSEIF HighlightedOption% = 5 THEN
  242.           GDTMinutes% = GDTMinutes% + Increment%
  243.           IF GDTMinutes% >= 60 THEN GDTMinutes% = 0
  244.         ELSEIF HighlightedOption% = 6 THEN
  245.           GDTSeconds% = GDTSeconds% + Increment%
  246.           IF GDTSeconds% >= 60 THEN GDTSeconds% = 0
  247.         END IF
  248.         HaltAndDisplay% = TRUE%
  249.       CASE CHR$(27)
  250.         GDTMonth% = VAL(LEFT$(DATE$, 2))
  251.         GDTDay% = VAL(MID$(DATE$, 4, 2))
  252.         GDTYear% = VAL(RIGHT$(DATE$, 4))
  253.         GDTHours% = VAL(LEFT$(TIME$, 2))
  254.         GDTMinutes% = VAL(MID$(TIME$, 4, 2))
  255.         GDTSeconds% = VAL(RIGHT$(TIME$, 2))
  256.         HaltAndDisplay% = TRUE%
  257.       CASE "X", "x"
  258.         SYSTEM
  259.       CASE CHR$(13)
  260.         GDTRtn$ = ""
  261.         IF GDTYear% < 10 THEN
  262.           GDTRtn$ = "000"
  263.         ELSEIF GDTYear% >= 10 AND GDTYear% < 100 THEN GDTRtn$ = "00"
  264.         ELSEIF GDTYear% >= 100 AND GDTYear% < 1000 THEN GDTRtn$ = "0": END IF
  265.         GDTRtn$ = GDTRtn$ + S$(GDTYear%) + ":"
  266.         tempDay% = 0: tempDay% = DaysPassedJanFromMonthDayYear(GDTMonth%, GDTDay%, GDTYear%)
  267.         IF tempDay% < 10 THEN
  268.           GDTRtn$ = GDTRtn$ + "00"
  269.         ELSEIF tempDay% >= 10 AND tempDay% < 100 THEN GDTRtn$ = GDTRtn$ + "0": END IF
  270.         GDTRtn$ = GDTRtn$ + S$(tempDay%) + ":"
  271.         IF GDTHours% < 10 THEN GDTRtn$ = GDTRtn$ + "0"
  272.         GDTRtn$ = GDTRtn$ + S$(GDTHours%) + ":"
  273.         IF GDTMinutes% < 10 THEN GDTRtn$ = GDTRtn$ + "0"
  274.         GDTRtn$ = GDTRtn$ + S$(GDTMinutes%) + ":"
  275.         IF GDTSeconds% < 10 THEN GDTRtn$ = GDTRtn$ + "0"
  276.         GDTRtn$ = GDTRtn$ + S$(GDTSeconds%)
  277.     END SELECT
  278.   LOOP UNTIL UserCommand$ = CHR$(13)
  279.   GetDateAndTime$ = GDTRtn$
  280.  
  281. FUNCTION ClockString$ (CSHours%, CSMinutes%, CSSeconds%)
  282.   DisplayHours$ = "": CSRtn$ = "": AmPm$ = ""
  283.  
  284.   IF CSHours% = 0 THEN
  285.     DisplayHours$ = "12"
  286.     AmPm$ = "AM"
  287.   ELSEIF CSHours% >= 1 AND CSHours% <= 11 THEN
  288.     DisplayHours$ = S$(CSHours%)
  289.     AmPm$ = "AM"
  290.   ELSEIF CSHours% = 12 THEN
  291.     DisplayHours$ = "12"
  292.     AmPm$ = "PM"
  293.   ELSEIF CSHours% > 12 AND CSHours% <= 23 THEN
  294.     DisplayHours$ = S$(CSHours% - 12)
  295.     AmPm$ = "PM"
  296.   END IF
  297.  
  298.   CSRtn$ = DisplayHours$ + ":"
  299.   IF CSMinutes% < 10 THEN CSRtn$ = CSRtn$ + "0"
  300.   CSRtn$ = CSRtn$ + S$(CSMinutes%) + " " + AmPm$ + " and " + S$(CSSeconds%) + " second"
  301.   IF CSSeconds% <> 1 THEN CSRtn$ = CSRtn$ + "s"
  302.  
  303.   ClockString$ = CSRtn$
  304.  
  305.  
  306. FUNCTION GetDate$ (Header$)
  307.   xPos% = 0: yPos% = 0: MaxOption% = 0: HighlightedOption% = 0
  308.   HaltAndDisplay% = 0: UserCommand$ = "": Instructions$ = "": TimerStarted% = 0: FirstTime% = 0: TimeElapsed% = 0
  309.   GDMonth% = 0: GDDay% = 0: GDYear% = 0: MW$ = "": Increment% = 0: MinOption% = 0: HeaderCopy$ = "": GDRtn$ = ""
  310.  
  311.   HaltAndDisplay% = TRUE%: yPos% = 22: xPos% = 19: HighlightedOption% = 1: Increment% = 1
  312.   MaxOption% = 3: MinOption% = 1: HeaderCopy$ = Header$
  313.   GDMonth% = VAL(LEFT$(DATE$, 2)): GDDay% = VAL(MID$(DATE$, 4, 2)): GDYear% = VAL(RIGHT$(DATE$, 4))
  314.   TimerStarted% = FALSE
  315.  
  316.   DO
  317.     UserCommand$ = INKEY$
  318.     IF HaltAndDisplay% = TRUE% THEN
  319.       HeaderCopy$ = Header$
  320.       COLOR 14, 1: CLS
  321.       COLOR 15
  322.       IF LEN(Header$) >= 50 THEN
  323.         LOCATE 7, 1: PRINT LongCenter(HeaderCopy$, 50, FALSE%)
  324.       ELSE LOCATE 7, Center(HeaderCopy$): PRINT HeaderCopy$: END IF
  325.       COLOR 12, 1: Instructions$ = "Use the arrow keys to select the date - Push [ESC] to reset - Push "
  326.       Instructions$ = Instructions$ + CHR$(34) + "X" + CHR$(34) + " to exit to the system - "
  327.       Instructions$ = Instructions$ + "Push [ENTER] when you have selected the desired date"
  328.       LOCATE yPos% + 20, 1: PRINT LongCenter$(Instructions$, 60, FALSE%)
  329.  
  330.       LOCATE yPos% - 5, xPos%: IF HighlightedOption% = 1 THEN
  331.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Month"
  332.       MW$ = "": MW$ = MonthWord$(GDMonth% - 1): COLOR 14, 1
  333.       LOCATE yPos% - 2, CenterBetween(MW$, xPos% - 3, xPos% + 8): PRINT MW$
  334.       MW$ = "": MW$ = MonthWord$(GDMonth%): COLOR 10, 0
  335.       LOCATE yPos%, CenterBetween(MW$, xPos% - 3, xPos% + 8): PRINT MW$
  336.       MW$ = "": MW$ = MonthWord$(GDMonth% + 1): COLOR 14, 1
  337.       LOCATE yPos% + 2, CenterBetween(MW$, xPos% - 3, xPos% + 8): PRINT MW$
  338.  
  339.       LOCATE yPos% - 5, xPos% + 20: IF HighlightedOption% = 2 THEN
  340.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Day"
  341.       COLOR 14, 1: O% = 0: O% = CorrectDay(GDMonth%, GDDay% - 1, GDYear%)
  342.       OP$ = "": OP$ = S$(O%) + Suffix$(O%)
  343.       LOCATE yPos% - 2, CenterBetween(OP$, xPos% + 19, xPos% + 22): PRINT OP$
  344.       COLOR 10, 0: OP$ = "": O% = 0: OP$ = S$(GDDay%) + Suffix$(GDDay%)
  345.       LOCATE yPos%, CenterBetween(OP$, xPos% + 19, xPos% + 22): PRINT OP$
  346.       COLOR 14, 1: O% = 0: O% = CorrectDay(GDMonth%, GDDay% + 1, GDYear%)
  347.       OP$ = "": OP$ = S$(O%) + Suffix$(O%)
  348.       LOCATE yPos% + 2, CenterBetween(OP$, xPos% + 19, xPos% + 22): PRINT OP$
  349.  
  350.       LOCATE yPos% - 5, xPos% + 40: IF HighlightedOption% = 3 THEN
  351.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Year"
  352.       COLOR 14, 1: O% = 0: O% = GDYear% - 1: IF O% = -1 THEN O% = 9999
  353.       LOCATE yPos% - 2, CenterBetween(S$(O%), xPos% + 40, xPos% + 44): PRINT S$(O%)
  354.       COLOR 10, 0: LOCATE yPos%, CenterBetween(S$(GDYear%), xPos% + 40, xPos% + 44): PRINT S$(GDYear%)
  355.       COLOR 14, 1: O% = 0: O% = GDYear% + 1: IF O% > 9999 THEN O% = 0
  356.       LOCATE yPos% + 2, CenterBetween(S$(O%), xPos% + 40, xPos% + 44): PRINT S$(O%)
  357.  
  358.       COLOR 10, 0: a$ = "": a$ = WrittenOutDate$(GDMonth%, GDDay%, GDYear%)
  359.       LOCATE yPos% + 10, Center(a$): PRINT a$
  360.  
  361.       HaltAndDisplay% = FALSE%
  362.     END IF
  363.  
  364.     SomeKey% = _KEYHIT
  365.     IF SomeKey% = UpKeyHit% OR SomeKey% = DownKeyHit% THEN
  366.       IF TimerStarted% = FALSE% THEN
  367.         FirstTime% = TIMER
  368.         TimerStarted% = TRUE%
  369.       END IF
  370.     END IF
  371.     IF SomeKey% < 0 THEN
  372.       FirstTime% = 0
  373.       Increment% = 1
  374.       TimeElapsed% = 0
  375.       TimerStarted% = FALSE%
  376.     END IF
  377.     TimeElapsed% = ABS(TIMER - FirstTime%)
  378.     IF TimeElapsed% = 2 THEN
  379.       IF HighlightedOption% = 3 THEN Increment% = 15
  380.     ELSEIF TimeElapsed% = 3 THEN
  381.       IF HighlightedOption% = 2 THEN Increment% = 2
  382.       IF HighlightedOption% = 3 THEN Increment% = 25
  383.     ELSEIF TimeElapsed% = 4 THEN
  384.       IF HighlightedOption% = 3 THEN Increment% = 35
  385.     ELSEIF TimeElapsed% = 6 THEN
  386.       IF HighlightedOption% = 3 THEN Increment% = 65
  387.     END IF
  388.  
  389.     SELECT CASE UserCommand$
  390.       CASE UpArrowKey$
  391.         IF HighlightedOption% = 1 THEN
  392.           GDMonth% = GDMonth% - Increment%
  393.           IF GDMonth% <= 0 THEN GDMonth% = 12
  394.           IF GDMonth% = 4 OR GDMonth% = 6 OR GDMonth% = 9 OR GDMonth% = 11 THEN
  395.             IF GDDay% = 31 THEN GDDay% = 30:
  396.           ELSEIF GDMonth% = 2 THEN
  397.             IF GDDay% > 29 AND GDYear% MOD 4 = 0 THEN
  398.               GDDay% = 29
  399.             ELSEIF GDDay% >= 29 AND GDYear% MOD 4 <> 0 THEN GDDay% = 28
  400.             END IF
  401.           END IF
  402.         ELSEIF HighlightedOption% = 2 THEN
  403.           GDDay% = GDDay% - Increment%
  404.           IF GDDay% <= 0 THEN
  405.             IF GDMonth% = 4 OR GDMonth% = 6 OR GDMonth% = 9 OR GDMonth% = 11 THEN
  406.               GDDay% = 30
  407.             ELSEIF GDMonth% = 2 AND GDYear% MOD 4 = 0 THEN GDDay% = 29
  408.             ELSEIF GDMonth% = 2 AND GDYear% MOD 4 <> 0 THEN GDDay% = 28
  409.             ELSE GDDay% = 31: END IF
  410.           END IF
  411.         ELSEIF HighlightedOption% = 3 THEN
  412.           GDYear% = GDYear% - Increment%
  413.           IF GDYear% < 0 THEN GDYear% = 9999
  414.           GDDay% = CorrectDay%(GDMonth%, GDDay%, GDYear%)
  415.         END IF
  416.         HaltAndDisplay% = TRUE%
  417.       CASE DownArrowKey$
  418.         IF HighlightedOption% = 1 THEN
  419.           GDMonth% = GDMonth% + Increment%
  420.           IF GDMonth% > 12 THEN GDMonth% = 1
  421.           GDDay% = CorrectDay%(GDMonth%, GDDay%, GDYear%)
  422.         ELSEIF HighlightedOption% = 2 THEN
  423.           GDDay% = GDDay% + Increment%
  424.           IF GDDay% >= 29 THEN GDDay% = CorrectDay(GDMonth%, GDDay%, GDYear%)
  425.         ELSEIF HighlightedOption% = 3 THEN
  426.           GDYear% = GDYear% + Increment%
  427.           IF GDYear% > 9999 THEN GDYear% = 0
  428.           GDDay% = CorrectDay%(GDMonth%, GDDay%, GDYear%)
  429.         END IF
  430.         HaltAndDisplay% = TRUE%
  431.       CASE RightArrowKey$
  432.         HighlightedOption% = HighlightedOption% + 1
  433.         IF HighlightedOption% > MaxOption% THEN HighlightedOption% = MinOption%
  434.         HaltAndDisplay% = TRUE%
  435.       CASE LeftArrowKey$
  436.         HighlightedOption% = HighlightedOption% - 1
  437.         IF HighlightedOption% < MinOption% THEN HighlightedOption% = MaxOption%
  438.         HaltAndDisplay% = TRUE%
  439.       CASE CHR$(27)
  440.         GDMonth% = VAL(LEFT$(DATE$, 2))
  441.         GDDay% = VAL(MID$(DATE$, 4, 2))
  442.         GDYear% = VAL(RIGHT$(DATE$, 4))
  443.       CASE "X", "x"
  444.         SYSTEM
  445.       CASE CHR$(13)
  446.         GDRtn$ = ""
  447.         GDRtn$ = MakeFormattedDATE$(GDMonth%, GDDay%, GDYear%)
  448.     END SELECT
  449.   LOOP UNTIL UserCommand$ = CHR$(13)
  450.   GetDate$ = GDRtn$
  451.  
  452. FUNCTION MakeFormattedDATE$ (MFMonth%, MFDay%, MFYear%)
  453.   MFDRtn$ = ""
  454.  
  455.   IF MFMonth% < 10 THEN MFDRtn$ = "0"
  456.   MFDRtn$ = MFDRtn$ + S$(MFMonth%) + "/"
  457.   IF MFDay% < 10 THEN MFDRtn$ = MFDRtn$ + "0"
  458.   MFDRtn$ = MFDRtn$ + S$(MFDay%) + "/"
  459.   IF MFYear% < 10 THEN
  460.     MFDRtn$ = MFDRtn$ + "000"
  461.   ELSEIF MFYear% >= 10 AND MFYear% < 100 THEN MFDRtn$ = MFDRtn$ + "00"
  462.   ELSEIF MFYear% >= 100 AND MFYear% < 1000 THEN MFDRtn$ = MFDRtn$ + "0": END IF
  463.   MFDRtn$ = MFDRtn$ + S$(MFYear%)
  464.  
  465.   MakeFormattedDATE$ = MFDRtn$
  466.  
  467.  
  468. FUNCTION WrittenOutDate$ (WODMonth%, WODDay%, WODYear%)
  469.   WODRtn$ = ""
  470.   WODRtn$ = MonthWord$(WODMonth%)
  471.   WODRtn$ = WODRtn$ + " "
  472.   WODRtn$ = WODRtn$ + S$(WODDay%) + Suffix(WODDay%)
  473.   WODRtn$ = WODRtn$ + ", "
  474.   WODRtn$ = WODRtn$ + S$(WODYear%)
  475.  
  476.   WrittenOutDate$ = WODRtn$
  477.  
  478. FUNCTION CorrectDay% (CDMonth%, CDDay%, CDYear%)
  479.   CDRtn% = 0
  480.  
  481.   SELECT CASE CDDay%
  482.     CASE IS <= 0
  483.       IF CDMonth% = 1 OR CDMonth% = 3 OR CDMonth% = 5 OR CDMonth% = 7 OR CDMonth% = 8 OR CDMonth% = 10 OR CDMonth% = 12 THEN
  484.         CDRtn% = 31
  485.       ELSEIF CDMonth% = 4 OR CDMonth% = 6 OR CDMonth% = 9 OR CDMonth% = 11 THEN
  486.         CDRtn% = 30
  487.       ELSEIF CDMonth% = 2 THEN
  488.         IF CDYear% MOD 4 = 0 THEN
  489.         CDRtn% = 29: ELSE CDRtn% = 28: END IF
  490.       END IF
  491.     CASE 29
  492.       IF CDMonth% = 2 AND CDYear% MOD 4 <> 0 THEN
  493.         CDRtn% = 1
  494.       ELSE CDRtn% = CDDay%: END IF
  495.     CASE 30
  496.       IF CDMonth% = 2 AND CDYear% MOD 4 = 0 THEN
  497.       CDRtn% = 1: ELSE CDRtn% = CDDay%: END IF
  498.     CASE 31
  499.       IF CDMonth% = 4 OR CDMonth% = 6 OR CDMonth% = 9 OR CDMonth% = 11 THEN
  500.         CDRtn% = 1
  501.       ELSE CDRtn% = CDDay%: END IF
  502.     CASE IS >= 32
  503.       CDRtn% = 1
  504.     CASE ELSE
  505.       CDRtn% = CDDay%
  506.   CorrectDay% = CDRtn%
  507.  
  508. FUNCTION CenterBetween% (text$, MinX%, MaxX%)
  509.   CBRtn% = 0
  510.   IF LEN(text$) + MinX% >= MaxX% THEN
  511.     CBRtn% = MinX%
  512.   ELSE
  513.     CBRtn% = INT((MaxX% - MinX% - LEN(text$)) / 2) + MinX%
  514.   END IF
  515.   CenterBetween = CBRtn%
  516.  
  517. SUB FromNowUntil
  518.   FNUMonth% = 0: FNUDay% = 0: FNUYear% = 0: FNUHour% = 0: FNUMinute% = 0: FNUSecond% = 0
  519.   FNUHeader$ = "": FNUTargetFormatDATE$ = "": FNUTargetMonth% = 0: FNUTargetDay% = 0: FNUTargetYear% = 0
  520.   FNUTargetFormatTIME$ = "": FNUTargetHour% = 0: FNUTargetMinute% = 0: FNUTargetSecond% = 0: FNUTargetDayCopy% = 0
  521.   FNUFinalDay% = 0: FNUFinalMonth% = 0: FNUFinalYear% = 0: FNUFinalHour% = 0: FNUFinalMinute% = 0: FNUFinalSecond% = 0
  522.   a$ = "": LeftChar$ = ""
  523.  
  524.   FNUMonth% = VAL(LEFT$(DATE$, 2))
  525.   FNUDay% = VAL(MID$(DATE$, 4, 2))
  526.   FNUYear% = VAL(RIGHT$(DATE$, 4))
  527.   FNUDay% = DaysPassedJanFromMonthDayYear(FNUMonth%, FNUDay%, FNUYear%)
  528.   FNUHour% = VAL(LEFT$(TIME$, 2))
  529.   FNUMinute% = VAL(MID$(TIME$, 4, 2))
  530.   FNUSecond% = VAL(RIGHT$(TIME$, 2))
  531.  
  532.   FNUHeader$ = "Select A Target Date$"
  533.   FNUTargetFormatDATE$ = GetDate$(FNUHeader$)
  534.   FNUTargetMonth% = VAL(LEFT$(FNUTargetFormatDATE$, 2))
  535.   FNUTargetDay% = VAL(MID$(FNUTargetFormatDATE$, 4, 2))
  536.   FNUTargetDayCopy% = FNUTargetDay%
  537.   FNUTargetYear% = VAL(RIGHT$(FNUTargetFormatDATE$, 4))
  538.   FNUTargetDay% = DaysPassedJanFromMonthDayYear(FNUTargetMonth%, FNUTargetDay%, FNUTargetYear%)
  539.  
  540.   FNUHeader$ = ""
  541.   FNUHeader$ = "Select A Target Time On " + WrittenOutDate$(FNUTargetMonth%, FNUTargetDayCopy%, FNUTargetYear%)
  542.   FNUTargetFormatTIME$ = GetTime$(FNUHeader$)
  543.   FNUTargetHour% = VAL(LEFT$(FNUTargetFormatTIME$, 2))
  544.   FNUTargetMinute% = VAL(MID$(FNUTargetFormatTIME$, 4, 4))
  545.   FNUTargetSecond% = VAL(RIGHT$(FNUTargetFormatTIME$, 2))
  546.  
  547.   FNUFinalSecond% = FNUTargetSecond% - FNUSecond%
  548.   IF FNUFinalSecond% < 0 THEN
  549.     FNUTargetMinute% = FNUTargetMinute% - 1
  550.     FNUFinalSecond% = FNUFinalSecond% + 60
  551.   END IF
  552.   FNUFinalMinute% = FNUTargetMinute% - FNUMinute%
  553.   IF FinalMinute% < 0 THEN
  554.     FNUTargetHour% = FNUTargetHour% - 1
  555.     FNUFinalMinute% = FNUFinalMinute% + 60
  556.   END IF
  557.   FNUFinalHour% = FNUTargetHour% - FNUHour%
  558.   IF FNUFinalHour% < 0 THEN
  559.     FNUFinalHour% = FNUFinalHour% + 60
  560.     FNUTargetDay% = FNUTargetDay% - 1
  561.   END IF
  562.   FNUFinalDay% = FNUTargetDay% - FNUDay%
  563.   IF FNUFinalDay% < 0 THEN
  564.     FNUFinalDay% = FNUFinalDay% + 366
  565.     FNUTargetYear% = FNUTargetYear% - 1
  566.   END IF
  567.   FNUFinalYear% = FNUTargetYear% - FNUYear%
  568.  
  569.   COLOR 14, 1: CLS
  570.   IF FNUFinalYear% < 0 THEN
  571.     a$ = "": a$ = "The selected date and time is before now"
  572.     LOCATE 25, Center(a$)
  573.     PRINT a$
  574.   ELSE
  575.     a$ = "": a$ = MakeElapsedTimeShort$(FNUFinalYear%, FNUFinalDay%, FNUFinalHour%, FNUFinalMinute%, FNUFinalSecond%)
  576.     a$ = ElapsedTimeWrittenOut$(a$)
  577.     IF VAL(LEFT$(a$, 2)) = 1 THEN
  578.       b$ = "There is"
  579.     ELSE b$ = "There are": END IF
  580.     LOCATE 15, Center(b$): PRINT b$
  581.     LOCATE 20, Center(a$): PRINT a$
  582.     LOCATE 25, Center("until"): PRINT "until"
  583.     a$ = "": a$ = WrittenOutDate$(FNUTargetMonth%, FNUTargetDayCopy%, FNUTargetYear%)
  584.     LOCATE 30, Center(a$): PRINT a$
  585.     LOCATE 32, Center("at"): PRINT "at"
  586.     a$ = "": a$ = ClockString$(FNUTargetHour%, FNUTargetMinute%, FNUTargetSecond%)
  587.     LOCATE 34, Center(a$): PRINT a$
  588.   END IF
  589.  
  590.   a$ = "": a$ = "Hit any key to continue"
  591.   LOCATE 48, Center(a$): PRINT a$: ll$ = P$
  592.  
  593. FUNCTION MakeElapsedTimeShort$ (MEYears%, MEDays%, MEHours%, MEMinutes%, MESeconds%)
  594.   METSRtn$ = ""
  595.  
  596.   IF MEYears% < 10 THEN
  597.     METSRtn$ = "000"
  598.   ELSEIF MEYears% >= 10 AND MEYears% < 100 THEN METSRtn$ = "00"
  599.   ELSEIF MEYears% >= 100 AND MEYears% < 1000 THEN METSRtn$ = "0": END IF
  600.   METSRtn$ = METSRtn$ + S$(MEYears%) + ":"
  601.  
  602.   IF MEDays% < 10 THEN
  603.     METSRtn$ = METSRtn$ + "00"
  604.   ELSEIF MEDays% >= 10 AND MEDays% < 100 THEN
  605.   METSRtn$ = METSRtn$ + "0": END IF
  606.   METSRtn$ = METSRtn$ + S$(MEDays%) + ":"
  607.  
  608.   IF MEHours% < 10 THEN METSRtn$ = METSRtn$ + "0"
  609.   METSRtn$ = METSRtn$ + S$(MEHours%) + ":"
  610.  
  611.   IF MEMinutes% < 10 THEN METSRtn$ = METSRtn$ + "0"
  612.   METSRtn$ = METSRtn$ + S$(MEMinutes%) + ":"
  613.  
  614.   IF MESeconds% < 10 THEN METSRtn$ = METSRtn$ + "0"
  615.   METSRtn$ = METSRtn$ + S$(MESeconds%)
  616.  
  617.   MakeElapsedTimeShort$ = METSRtn$
  618.  
  619. FUNCTION ElapsedTimeWrittenOut$ (TimeShortString$)
  620.   ETWORtn$ = "": Years3% = 0: Days3% = 0: Hours3% = 0: Minutes3% = 0: Seconds3% = 0
  621.  
  622.   Years3% = VAL(LEFT$(TimeShortString$, 4))
  623.   Days3% = VAL(MID$(TimeShortString$, 6, 3))
  624.   Hours3% = VAL(MID$(TimeShortString$, 10, 2))
  625.   Minutes3% = VAL(MID$(TimeShortString$, 13, 2))
  626.   Seconds3% = VAL(RIGHT$(TimeShortString$, 2))
  627.  
  628.   IF Years3% <> 0 THEN
  629.     IF Years3% >= 1000 AND Years3% <= 9999 THEN
  630.       lftNum% = INT(Years3% / 1000)
  631.       ETWORtn$ = S$(lftNum%) + ","
  632.       rtNum% = Years3% - (lftNum% * 1000)
  633.       IF rtNum% < 10 THEN
  634.         ETWORtn$ = ETWORtn$ + "00"
  635.       ELSEIF rtNum% >= 10 AND rtNum% < 100 THEN
  636.         ETWORtn$ = ETWORtn$ + "0"
  637.       END IF
  638.       ETWORtn$ = ETWORtn$ + S$(rtNum%)
  639.     ELSE
  640.       ETWORtn$ = S$(Years3%)
  641.     END IF
  642.     ETWORtn$ = ETWORtn$ + " Year"
  643.     IF Years3% <> 1 THEN ETWORtn$ = ETWORtn$ + "s"
  644.     IF Days3% <> 0 AND (Hours3% <> 0 OR Minutes3% <> 0 OR Seconds3% <> 0) THEN
  645.       ETWORtn$ = ETWORtn$ + ", "
  646.     ELSEIF Days3% <> 0 AND (Hours3% = 0 AND Minutes3% = 0 AND Seconds3% = 0) THEN
  647.       ETWORtn$ = ETWORtn$ + " and "
  648.     ELSEIF Hours3% <> 0 AND (Minutes3% <> 0 OR Seconds3% <> 0) THEN
  649.       ETWORtn$ = ETWORtn$ + ", "
  650.     ELSEIF Hours3% <> 0 AND Minutes3% = 0 AND Seconds3% = 0 THEN
  651.       ETWORtn$ = ETWORtn$ + " and "
  652.     ELSEIF Minutes3% <> 0 AND Seconds3% <> 0 THEN
  653.       ETWORtn$ = ETWORtn$ + ", "
  654.     ELSEIF Minutes3% <> 0 XOR Seconds3% <> 0 THEN
  655.       ETWORtn$ = ETWORtn$ + " and "
  656.     END IF
  657.   END IF
  658.   IF Days3% <> 0 THEN
  659.     ETWORtn$ = ETWORtn$ + S$(Days3%) + " Day"
  660.     IF Days3% <> 1 THEN ETWORtn$ = ETWORtn$ + "s"
  661.     IF Hours3% <> 0 AND (Minutes3% <> 0 OR Seconds3% <> 0) THEN
  662.       ETWORtn$ = ETWORtn$ + ", "
  663.     ELSEIF Hours3% <> 0 AND Minutes3% = 0 AND Seconds3% = 0 THEN
  664.       ETWORtn$ = ETWORtn$ + " and "
  665.     ELSEIF Minutes3% <> 0 AND Seconds3% <> 0 THEN
  666.       ETWORtn$ = ETWORtn$ + ", "
  667.     ELSEIF Minutes3% <> 0 XOR Seconds3% <> 0 THEN
  668.       ETWORtn$ = ETWORtn$ + " and "
  669.     END IF
  670.   END IF
  671.   IF Hours3% <> 0 THEN
  672.     ETWORtn$ = ETWORtn$ + S$(Hours3%) + " hour"
  673.     IF Hours3% <> 1 THEN ETWORtn$ = ETWORtn$ + "s"
  674.     IF Minutes3% <> 0 AND Seconds3% <> 0 THEN
  675.       ETWORtn$ = ETWORtn$ + ", "
  676.     ELSEIF Minutes3% <> 0 XOR Seconds3% <> 0 THEN
  677.       ETWORtn$ = ETWORtn$ + " and "
  678.     END IF
  679.   END IF
  680.   IF Minutes3% <> 0 THEN
  681.     ETWORtn$ = ETWORtn$ + S$(Minutes3%) + " minute"
  682.     IF Minutes3% <> 1 THEN ETWORtn$ = ETWORtn$ + "s"
  683.     IF Seconds3% <> 0 THEN ETWORtn$ = ETWORtn$ + " and "
  684.   END IF
  685.   IF Seconds3% <> 0 THEN
  686.     ETWORtn$ = ETWORtn$ + S$(Seconds3%) + " second"
  687.     IF Seconds3% <> 1 THEN ETWORtn$ = ETWORtn$ + "s"
  688.   END IF
  689.   IF Years3% = 0 AND Days3% = 0 AND Hours3% = 0 AND Minutes3% = 0 AND Seconds3% = 0 THEN ETWORtn$ = "Nothing"
  690.   ElapsedTimeWrittenOut$ = ETWORtn$
  691.  
  692.  
  693. FUNCTION GetTime$ (GTHeader$)
  694.   HaltAndDisplay% = 0: GTHeaderCopy$ = "": Instructions$ = "": xPos% = 0: yPos% = 0: HighlightedOption% = 0
  695.   GTHours% = 0: GTMinutes% = 0: GTSeconds% = 0: SomeKey% = 0: TimerStarted% = 0: GTClock$ = ""
  696.   FirstTime% = 0: Increment% = 0: TimeElapsed% = 0: UserCommand$ = "": MaxOption% = 0: GTRtn$ = ""
  697.  
  698.   HaltAndDisplay% = TRUE%: xPos% = 13: yPos% = 25: HighlightedOption% = 1
  699.   GTHours% = VAL(LEFT$(TIME$, 2)): GTMinutes% = VAL(MID$(TIME$, 4, 2)): GTSeconds% = VAL(RIGHT$(TIME$, 2))
  700.   Increment% = 1: TimerStarted% = FALSE%: MaxOption% = 3
  701.  
  702.  
  703.   DO
  704.     UserCommand$ = INKEY$
  705.  
  706.     IF HaltAndDisplay% = TRUE% THEN
  707.       GTHeaderCopy$ = GTHeader$
  708.       COLOR 14, 1: CLS
  709.       COLOR 15
  710.       IF LEN(GTHeader$) >= 50 THEN
  711.         LOCATE 6, 1: PRINT LongCenter(GTHeaderCopy$, 50, FALSE%)
  712.       ELSE
  713.         LOCATE 7, Center(GTHeaderCopy$)
  714.         PRINT GTHeaderCopy$
  715.       END IF
  716.       COLOR 12, 1: Instructions$ = "Use the arrow keys to select the time. Push [ESC] to reset. Push "
  717.       Instructions$ = Instructions$ + CHR$(34) + "X" + CHR$(34) + " to exit to the system. Push [ENTER] when you have selected the desired time"
  718.       LOCATE 44, 1: PRINT LongCenter$(Instructions$, 60, FALSE%)
  719.  
  720.       IF HighlightedOption% = 1 THEN
  721.       COLOR 10, 0: ELSE COLOR 14, 1: END IF
  722.       LOCATE yPos% - 5, xPos%: PRINT "Hours"
  723.       LOCATE yPos% - 2, xPos% + 2
  724.       COLOR 14, 1:
  725.       IF GTHours% - 1 = -1 THEN
  726.         PRINT "11"
  727.       ELSEIF GTHours% - 1 = 0 THEN PRINT "12"
  728.       ELSEIF GTHours% - 1 > 0 AND GTHours% - 1 <= 12 THEN PRINT S$(GTHours% - 1)
  729.       ELSEIF GTHours% - 1 >= 13 AND GTHours% - 1 <= 23 THEN PRINT S$(GTHours% - 1 - 12): END IF
  730.       LOCATE yPos%, xPos% + 2: COLOR 10, 0
  731.       IF GTHours% = 0 THEN
  732.         PRINT "12"
  733.       ELSEIF GTHours% > 0 AND GTHours% <= 12 THEN PRINT S$(GTHours%)
  734.       ELSEIF GTHours% > 12 AND GTHours% < 24 THEN PRINT S$(GTHours% - 12): END IF
  735.       LOCATE yPos% + 2, xPos% + 2: COLOR 14, 1
  736.       IF GTHours% + 1 >= 1 AND GTHours% + 1 < 13 THEN
  737.         PRINT S$(GTHours% + 1)
  738.       ELSEIF GTHours% + 1 >= 13 AND GTHours% + 1 <= 24 THEN PRINT S$(GTHours% + 1 - 12): END IF
  739.  
  740.       IF HighlightedOption% = 2 THEN
  741.       COLOR 10, 0: ELSE COLOR 14, 1: END IF
  742.       LOCATE yPos% - 5, xPos% + 16: PRINT "Minutes"
  743.       LOCATE yPos% - 2, xPos% + 18: COLOR 14, 1
  744.       IF GTMinutes% - 1 = -1 THEN
  745.         PRINT "59"
  746.       ELSEIF GTMinutes% - 1 >= 0 AND GTMinutes% - 1 <= 59 THEN
  747.         IF GTMinutes% - 1 < 10 THEN PRINT "0";:
  748.         PRINT S$(GTMinutes% - 1)
  749.       END IF
  750.       LOCATE yPos%, xPos% + 18: COLOR 10, 0: IF GTMinutes% < 10 THEN PRINT "0";
  751.       PRINT S$(GTMinutes%)
  752.       LOCATE yPos% + 2, xPos% + 18: COLOR 14, 1
  753.       IF GTMinutes% + 1 >= 0 AND GTMinutes% + 1 <= 59 THEN
  754.         IF GTMinutes% + 1 < 10 THEN PRINT "0";
  755.         PRINT S$(GTMinutes% + 1)
  756.       ELSEIF GTMinutes% + 1 = 60 THEN PRINT "00"
  757.       END IF
  758.  
  759.       IF HighlightedOption% = 3 THEN
  760.       COLOR 10, 0: ELSE COLOR 14, 1: END IF
  761.       LOCATE yPos% - 5, xPos% + 32: PRINT "Seconds"
  762.       LOCATE yPos% - 2, xPos% + 36: COLOR 14, 1
  763.       IF GTSeconds% - 1 = -1 THEN
  764.         PRINT "59"
  765.       ELSEIF GTSeconds% - 1 >= 0 AND GTSeconds% <= 59 THEN
  766.         IF GTSeconds% - 1 < 10 THEN PRINT "0";
  767.         PRINT S$(GTSeconds% - 1)
  768.       END IF
  769.       LOCATE yPos%, xPos% + 36: COLOR 10, 0: IF GTSeconds% < 10 THEN PRINT "0";
  770.       PRINT S$(GTSeconds%)
  771.       LOCATE yPos% + 2, xPos% + 36: COLOR 14, 1
  772.       IF GTSeconds% + 1 >= 0 AND GTSeconds% + 1 <= 59 THEN
  773.         IF GTSeconds% + 1 < 10 THEN PRINT "0";
  774.         PRINT S$(GTSeconds% + 1)
  775.       ELSEIF GTSeconds% + 1 = 60 THEN PRINT "00": END IF
  776.  
  777.       LOCATE yPos% - 2, xPos% + 50: COLOR 14, 1
  778.       IF GTHours% - 1 >= 0 AND GTHours% - 1 <= 11 THEN
  779.       PRINT "AM": ELSE PRINT "PM": END IF
  780.       LOCATE yPos%, xPos% + 50: COLOR 10, 0
  781.       IF GTHours% < 12 THEN
  782.       PRINT "AM": ELSE PRINT "PM": END IF
  783.       LOCATE yPos% + 2, xPos% + 50: COLOR 14, 1
  784.       IF GTHours% + 1 >= 0 AND GTHours% + 1 <= 11 OR GTHours% + 1 = 24 THEN
  785.       PRINT "AM": ELSE: PRINT "PM": END IF
  786.  
  787.       GTClock$ = ClockString$(GTHours%, GTMinutes%, GTSeconds%)
  788.       COLOR 10, 0: LOCATE ypos + 34, Center(GTClock$): PRINT GTClock$
  789.  
  790.       HaltAndDisplay% = FALSE%
  791.     END IF
  792.  
  793.     SomeKey% = _KEYHIT
  794.     IF SomeKey% = UpKeyHit% OR SomeKey% = DownKeyHit% THEN
  795.       IF TimerStarted% = FALSE% THEN
  796.         FirstTime% = TIMER
  797.         TimerStarted% = TRUE%
  798.       END IF
  799.     END IF
  800.     IF SomeKey% < 0 THEN
  801.       FirstTime% = 0
  802.       Increment% = 1
  803.       TimeElapsed% = 0
  804.       TimerStarted% = FALSE%
  805.     END IF
  806.     TimeElapsed% = ABS(TIMER - FirstTime%)
  807.     IF TimeElapsed% = 2 THEN
  808.       IF HighlightedOption% = 2 OR HighlightedOption% = 3 THEN Increment% = 3
  809.     END IF
  810.  
  811.     SELECT CASE UserCommand$
  812.       CASE UpArrowKey$
  813.         IF HighlightedOption% = 1 THEN
  814.           GTHours% = GTHours% - Increment%
  815.           IF GTHours% < 0 THEN GTHours% = 23
  816.         ELSEIF HighlightedOption% = 2 THEN
  817.           GTMinutes% = GTMinutes% - Increment%
  818.           IF GTMinutes% < 0 THEN GTMinutes% = 59
  819.         ELSEIF HighlightedOption% = 3 THEN
  820.           GTSeconds% = GTSeconds% - Increment%
  821.           IF GTSeconds% < 0 THEN GTSeconds% = 59
  822.         END IF
  823.         HaltAndDisplay% = TRUE
  824.       CASE DownArrowKey$
  825.         IF HighlightedOption% = 1 THEN
  826.           GTHours% = GTHours% + Increment%
  827.           IF GTHours% > 23 THEN GTHours% = 0
  828.         ELSEIF HighlightedOption% = 2 THEN
  829.           GTMinutes% = GTMinutes% + Increment%
  830.           IF GTMinutes% > 59 THEN GTMinutes% = 0
  831.         ELSEIF HighlightedOption% = 3 THEN
  832.           GTSeconds% = GTSeconds% + Increment%
  833.           IF GTSeconds% > 59 THEN GTSeconds% = 0
  834.         END IF
  835.         HaltAndDisplay% = TRUE
  836.       CASE LeftArrowKey$
  837.         HighlightedOption% = HighlightedOption% - 1
  838.         IF HighlightedOption% = 0 THEN HighlightedOption% = MaxOption%
  839.         HaltAndDisplay% = TRUE
  840.       CASE RightArrowKey$
  841.         HighlightedOption% = HighlightedOption% + 1
  842.         IF HighlightedOption% > MaxOption% THEN HighlightedOption% = 1
  843.         HaltAndDisplay% = TRUE
  844.       CASE CHR$(13)
  845.         GTRtn$ = MakeFormattedTIME$(GTHours%, GTMinutes%, GTSeconds%)
  846.       CASE CHR$(27)
  847.         GTHours% = VAL(LEFT$(TIME$, 2))
  848.         GTMinutes% = VAL(MID$(TIME$, 4, 2))
  849.         GTSeconds% = VAL(RIGHT$(TIME$, 2))
  850.         HaltAndDisplay% = TRUE%
  851.       CASE "X", "x"
  852.         SYSTEM
  853.     END SELECT
  854.   LOOP UNTIL UserCommand$ = CHR$(13)
  855.  
  856.   GetTime$ = GTRtn$
  857.  
  858. FUNCTION MakeFormattedTIME$ (MFHours%, MFMinutes%, MFSeconds%)
  859.   MFTRtn$ = ""
  860.  
  861.   IF MFHours% < 10 THEN MFTRtn$ = "0"
  862.   MFTRtn$ = MFTRtn$ + S$(MFHours%) + ":"
  863.   IF MFMinutes% < 10 THEN MFTRtn$ = MFTRtn$ + "0"
  864.   MFTRtn$ = MFTRtn$ + S$(MFMinutes%) + ":"
  865.   IF MFSeconds% < 10 THEN MFTRtn$ = MFTRtn$ + "0"
  866.   MFTRtn$ = MFTRtn$ + S$(MFSeconds%)
  867.  
  868.   MakeFormattedTIME$ = MFTRtn$
  869.  
  870.  
  871. FUNCTION LongCenter$ (Text$, CutHere%, BlankLineBetween%)
  872.   PartString$ = "": Spaces$ = "": CutString$ = "": LCRtn$ = "": LastSpaces$ = ""
  873.   NumLastSpaces% = 0
  874.  
  875.   CutHere% = CutHere% + 1
  876.   DO
  877.     DO
  878.       CutHere% = CutHere% - 1
  879.       Cutting$ = MID$(Text$, CutHere%, 1)
  880.     LOOP UNTIL Cutting$ = " "
  881.     PartString$ = MID$(Text$, 1, CutHere%)
  882.     Text$ = MID$(Text$, CutHere% + 1, LEN(Text$))
  883.     Spaces$ = STRING$(Center(PartString$), " ")
  884.     CutString$ = Spaces$ + PartString$ + Spaces$
  885.     LCRtn$ = LCRtn$ + CutString$
  886.     IF BlankLineBetween% = TRUE% THEN LCRtn$ = LCRtn$ + STRING$(80, " ")
  887.   LOOP UNTIL LEN(Text$) < CutHere%
  888.   NumLastSpaces% = Center(Text$)
  889.   LastSpaces$ = STRING$(NumLastSpaces%, " ")
  890.   LCRtn$ = LCRtn$ + LastSpaces$ + Text$
  891.   LongCenter$ = LCRtn$
  892.  
  893.  
  894. FUNCTION DaysPassedJanFromMonthDayYear% (Month9%, Day9%, Years9%)
  895.   DPJFMDYRtn% = 0: LeapYear% = 0
  896.  
  897.   IF Years9% MOD 4 = 0 THEN
  898.   LeapYear% = 1: ELSE LeapYear% = 0: END IF
  899.  
  900.   SELECT CASE Month9%
  901.     CASE 1
  902.       DPJFMDYRtn% = Day9%
  903.     CASE 2
  904.       DPJFMDYRtn% = 31 + Day9%
  905.     CASE 3
  906.       DPJFMDYRtn% = 31 + 28 + LeapYear% + Day9%
  907.     CASE 4
  908.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + Day9%
  909.     CASE 5
  910.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + Day9%
  911.     CASE 6
  912.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + Day9%
  913.     CASE 7
  914.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + Day9%
  915.     CASE 8
  916.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + Day9%
  917.     CASE 9
  918.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + 31 + Day9%
  919.     CASE 10
  920.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + 31 + 30 + Day9%
  921.     CASE 11
  922.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + Day9%
  923.     CASE 12
  924.       DPJFMDYRtn% = 31 + 28 + LeapYear% + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + Day9%
  925.   DaysPassedJanFromMonthDayYear = DPJFMDYRtn%
  926.  
  927. SUB HowLongSince
  928.   YearNow% = 0: DayNow% = 0: HourNow% = 0: MinuteNow% = 0: SecondNow% = 0: MonthNow% = 0
  929.   HLSTargetDateAndTime$ = "": Instructions$ = "": DayNowCopy% = 0: HLSTargetYear% = 0: HLSTargetDay% = 0
  930.   HLSTargetHour% = 0: HLSTargetMinute% = 0: HLSTargetSecond% = 0: HLSFinalYear% = 0: HLSFinalDay% = 0
  931.   HLSFinalHour% = 0: HLSFinalMinute% = 0: HLSFinalSecond% = 0: SecondNowCopy% = 0: MinuteNowCopy% = 0: HourNowCopy% = 0
  932.   DayNowCopy% = 0: YearNowCopy% = 0: HLSTargetMonth% = 0: HLSTargetDayCopy% = 0
  933.  
  934.   YearNow% = VAL(RIGHT$(DATE$, 4))
  935.   DayNow% = VAL(MID$(DATE$, 4, 2))
  936.   DayNowCopy% = DayNow%
  937.   MonthNow% = VAL(LEFT$(DATE$, 2))
  938.   DayNow% = DaysPassedJanFromMonthDayYear(MonthNow%, DayNow%, YearNow%)
  939.   HourNow% = VAL(LEFT$(TIME$, 2))
  940.   MinuteNow% = VAL(MID$(TIME$, 4, 2))
  941.   SecondNow% = VAL(RIGHT$(TIME$, 2))
  942.   YearNowCopy% = YearNow%
  943.   HourNowCopy% = HourNow%
  944.   MinuteNowCopy% = MinuteNow%
  945.   SecondNowCopy% = SecondNow%
  946.  
  947.   Instructions$ = "Select A Target Date and Time Before " + WrittenOutDate$(MonthNow%, DayNowCopy%, YearNow%)
  948.   Instructions$ = Instructions$ + " at " + ClockString$(HourNow%, MinuteNow%, SecondNow%)
  949.   HLSTargetDateAndTime$ = GetDateAndTime$(Instructions$)
  950.  
  951.   whatTheHellString$ = MID$(HLSTargetDateAndTime$, 6, 3)
  952.   whatTheHellInteger% = VAL(whatTheHellString$)
  953.   HLSTargetYear% = VAL(LEFT$(HLSTargetDateAndTime$, 4))
  954.   HLSTargetDay% = VAL(MID$(HLSTargetDateAndTime$, 6, 3))
  955.   HLSTargetHour% = VAL(MID$(HLSTargetDateAndTime$, 10, 2))
  956.   HLSTargetMinute% = VAL(MID$(HLSTargetDateAndTime$, 13, 2))
  957.   HLSTargetSecond% = VAL(RIGHT$(HLSTargetDateAndTime$, 2))
  958.   HLSTargetMonth% = MonthOrDayFromDaysPassedJan(HLSTargetDay%, 1, HLSTargetYear%)
  959.   HLSTargetDayCopy% = MonthOrDayFromDaysPassedJan(HLSTargetDay%, 2, HLSTargetYear%)
  960.  
  961.   HLSFinalSecond% = SecondNow% - HLSTargetSecond%
  962.   IF HLSFinalSecond% < 0 THEN
  963.     HLSFinalSecond% = HLSFinalSecond% + 60
  964.     MinuteNow% = MinuteNow% - 1
  965.   END IF
  966.   HLSFinalMinute% = MinuteNow% - HLSTargetMinute%
  967.   IF HLSFinalMinute% < 0 THEN
  968.     HLSFinalMinute% = HLSFinalMinute% + 60
  969.     HourNow% = HourNow% - 1
  970.   END IF
  971.   HLSFinalHour% = HourNow% - HLSTargetHour%
  972.   IF HLSFinalHour% < 0 THEN
  973.     HLSFinalHour% = HLSFinalHour% + 24
  974.     DayNow% = DayNow% - 1
  975.   END IF
  976.   HLSFinalDay% = DayNow% - whatTheHellInteger%
  977.   IF HLSFinalDay% < 0 THEN
  978.     HLSFinalDay% = HLSFinalDay% + 365
  979.     YearNow% = YearNow% - 1
  980.   END IF
  981.   HLSFinalYear% = YearNow% - HLSTargetYear%
  982.  
  983.   COLOR 14, 1: CLS
  984.   IF HLSFinalYear% < 0 THEN
  985.     a$ = "": a$ = "The selected date and time is after "
  986.     a$ = a$ + WrittenOutDate$(MonthNow%, DayNowCopy%, YearNowCopy%)
  987.     a$ = a$ + " at " + ClockString$(HourNowCopy%, MinuteNowCopy%, SecondNowCopy%)
  988.     LOCATE 24, 1
  989.     PRINT LongCenter$(a$, 50, TRUE%)
  990.   ELSE
  991.     a$ = "": a$ = WrittenOutDate$(HLSTargetMonth%, HLSTargetDayCopy%, HLSTargetYear%)
  992.     a$ = a$ + " at " + ClockString$(HLSTargetHour%, HLSTargetMinute%, HLSTargetSecond%)
  993.     a$ = a$ + " occurred "
  994.     a$ = a$ + ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(HLSFinalYear%, HLSFinalDay%, HLSFinalHour%, HLSFinalMinute%, HLSFinalSecond%))
  995.     a$ = a$ + " ago"
  996.     LOCATE 24, 1
  997.     PRINT LongCenter(a$, 50, TRUE%)
  998.   END IF
  999.   a$ = "Hit any key": LOCATE 48, Center(a$): PRINT a$: ll$ = P$
  1000.  
  1001. SUB WhatDateAfterElapsedTime
  1002.   TimePassed$ = "": YearsToday% = 0: MonthToday% = 0: DaysToday% = 0: DaysTodayAfterJan0% = 0: HoursToday% = 0: MinutesToday% = 0
  1003.   SecondsToday% = 0: YearsPassed% = 0: DaysPassed% = 0: HoursPassed% = 0: MinutesPassed% = 0: SecondsPassed% = 0
  1004.   ResultingYears% = 0: ResultingDaysPassedJan% = 0: ResultingDays% = 0: ResultingHours% = 0: ResultingMinutes% = 0
  1005.   ResultingSeconds% = 0: ResultingDateMonth% = 0: ResultingDateDay% = 0: ResultingDateYear% = 0: ResultingTimeHour% = 0
  1006.   ResultingTimeMinutes% = 0: ResultingTimeSeconds% = 0: AnswerString$ = ""
  1007.  
  1008.  
  1009.   YearsToday% = VAL(RIGHT$(DATE$, 4))
  1010.   DaysToday% = VAL(MID$(DATE$, 4, 2))
  1011.   MonthToday% = VAL(LEFT$(DATE$, 2))
  1012.   DaysTodayAfterJan0% = DaysPassedJanFromMonthDayYear(MonthToday%, DaysToday%, YearsToday%)
  1013.   HoursToday% = VAL(LEFT$(TIME$, 2))
  1014.   MinutesToday% = VAL(MID$(TIME$, 4, 2))
  1015.   SecondsToday% = VAL(RIGHT$(TIME$, 2))
  1016.  
  1017.   TimePassed$ = GetElapsedTime$("Find the date after how much time has passed?")
  1018.   YearsPassed% = VAL(LEFT$(TimePassed$, 4))
  1019.   DaysPassed% = VAL(MID$(TimePassed$, 6, 3))
  1020.   HoursPassed% = VAL(MID$(TimePassed$, 10, 2))
  1021.   MinutesPassed% = VAL(MID$(TimePassed$, 13, 2))
  1022.   SecondsPassed% = VAL(RIGHT$(TimePassed$, 2))
  1023.  
  1024.   ResultingSeconds% = SecondsToday% + SecondsPassed%
  1025.   IF ResultingSeconds% >= 60 THEN
  1026.     ResultingSeconds% = ResultingSeconds% - 60
  1027.     MinutesPassed% = MinutesPassed% + 1
  1028.   END IF
  1029.   ResultingMinutes% = MinutesToday% + MinutesPassed%
  1030.   IF ResultingMinutes% >= 60 THEN
  1031.     ResultingMinutes% = ResultingMinutes% - 60
  1032.     HoursPassed% = HoursPassed% + 1
  1033.   END IF
  1034.   ResultingHours% = HoursToday% + HoursPassed%
  1035.   IF ResultingHours% >= 24 THEN
  1036.     ResultingHours% = ResultingHours% - 24
  1037.     DaysPassed% = DaysPassed% + 1
  1038.   END IF
  1039.   ResultingDays% = DaysTodayAfterJan0% + DaysPassed%
  1040.   IF ResultingDays% >= 365 THEN
  1041.     ResultingDays% = ResultingDays% - 365
  1042.     YearsPassed% = YearsPassed% + 1
  1043.   END IF
  1044.   ResultingYears% = YearsToday% + YearsPassed%
  1045.   ResultingDateYear% = ResultingYears%
  1046.   ResultingDateMonth% = MonthOrDayFromDaysPassedJan(ResultingDays%, 1, ResultingDateYear%)
  1047.   ResultingDateDay% = MonthOrDayFromDaysPassedJan(ResultingDays%, 2, ResultingDateYear%)
  1048.   ResultingTimeHour% = ResultingHours%
  1049.   ResultingTimeMinutes% = ResultingMinutes%
  1050.   ResultingTimeSeconds% = ResultingSeconds%
  1051.   AnswerString$ = ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(YearsPassed%, DaysPassed%, HoursPassed%, MinutesPassed%, SecondsPassed%))
  1052.   AnswerString$ = AnswerString$ + " after now is "
  1053.   AnswerString$ = AnswerString$ + WrittenOutDate$(ResultingDateMonth%, ResultingDateDay%, ResultingDateYear%)
  1054.   AnswerString$ = AnswerString$ + " at " + ClockString$(ResultingTimeHour%, ResultingTimeMinutes%, ResultingTimeSeconds%)
  1055.   CLS
  1056.   LOCATE 23, 1
  1057.   PRINT LongCenter$(AnswerString$, 45, TRUE%)
  1058.   a$ = "": a$ = "Hit any key": LOCATE 48, Center(a$): PRINT a$: ll$ = P$
  1059.  
  1060. SUB AddElapsedTimes
  1061.   Years1% = 0: Years2% = 0: AddedYears% = 0: Days1% = 0: Days2% = 0: AddedDays% = 0: Hours1% = 0
  1062.   Hours2% = 0: AddedHours% = 0: Minutes1% = 0: Minutes2% = 0: AddedMinutes% = 0: Seconds1% = 0
  1063.   Seconds2% = 0: AddedSeconds% = 0: et1$ = "": et2$ = "": Prompt2$ = "": AnswerString$ = "": AT$ = ""
  1064.  
  1065.   et1$ = GetElapsedTime$("Select the fire time")
  1066.   Years1% = VAL(LEFT$(et1$, 4))
  1067.   Days1% = VAL(MID$(et1$, 6, 3))
  1068.   Hours1% = VAL(MID$(et1$, 10, 2))
  1069.   Minutes1% = VAL(MID$(et1$, 13, 2))
  1070.   Seconds1% = VAL(RIGHT$(et1$, 2))
  1071.  
  1072.   Prompt2$ = "Select the amount of time to add to " + ElapsedTimeWrittenOut$(et1$)
  1073.   et2$ = GetElapsedTime$(Prompt2$)
  1074.   Years2% = VAL(LEFT$(et2$, 4))
  1075.   Days2% = VAL(MID$(et2$, 6, 3))
  1076.   Hours2% = VAL(MID$(et2$, 10, 2))
  1077.   Minutes2% = VAL(MID$(et2$, 13, 2))
  1078.   Seconds2% = VAL(RIGHT$(et2$, 2))
  1079.  
  1080.   AddedSeconds% = Seconds1% + Seconds2%
  1081.   IF AddedSeconds% >= 60 THEN
  1082.     AddedSeconds% = AddedSeconds% - 60
  1083.     Minutes1% = Minutes1% + 1
  1084.   END IF
  1085.   AddedMinutes% = Minutes1% + Minutes2%
  1086.   IF AddedMinutes% >= 60 THEN
  1087.     AddedMinutes% = AddedMinutes% - 60
  1088.     Hours1% = Hours1% + 1
  1089.   END IF
  1090.   AddedHours% = Hours1% + Hours2%
  1091.   IF AddedHours% >= 24 THEN
  1092.     AddedHours% = AddedHours% - 24
  1093.     Days1% = Days1% + 1
  1094.   END IF
  1095.   AddedDays% = Days1% + Days2%
  1096.   IF AddedDays% >= 365 THEN
  1097.     AddedDays% = AddedDays% - 365
  1098.     Years1% = Years1% + 1
  1099.   END IF
  1100.   AddedYears% = Years1% + Years2%
  1101.  
  1102.   COLOR 14, 1: CLS
  1103.   AnswerString$ = ElapsedTimeWrittenOut$(et1$) + " added with " + ElapsedTimeWrittenOut$(et2$)
  1104.   ATShort$ = MakeElapsedTimeShort$(AddedYears%, AddedDays%, AddedHours%, AddedMinutes%, AddedSeconds%)
  1105.   AT$ = ElapsedTimeWrittenOut$(ATShort$)
  1106.   AnswerString$ = AnswerString$ + " equals " + AT$
  1107.   LOCATE 20, 1
  1108.   PRINT LongCenter$(AnswerString$, 50, TRUE%)
  1109.   ll$ = P$
  1110.  
  1111. SUB SubtractElapsedTimes
  1112.   Et1$ = "": Et2$ = "": Prompt1$ = "": Prompt2$ = "": Years1% = 0: Years2% = 0: SubtractedYears% = 0: Days1% = 0: Days2% = 0
  1113.   SubtractedDays% = 0: Hours1% = 0: Hours2% = 0: SubtractedHours% = 0: Minutes1% = 0: Minutes2% = 0: SubtractedMinutes% = 0
  1114.   Seconds1% = 0: Seconds2% = 0: SubtractedSeconds% = 0: BT% = 0: FirstYears% = 0: SecondYears% = 0: FirstDays% = 0: SecondDays% = 0
  1115.   FirstHours% = 0: SecondHours% = 0: FirstMinutes% = 0: SecondMinutes% = 0: FirstSeconds% = 0: SecondSeconds% = 0: Result$ = ""
  1116.   FTWO$ = "": STWO$ = "": SubTWO$ = ""
  1117.  
  1118.   Prompt1$ = "Select one of the 2 times"
  1119.   Et1$ = GetElapsedTime$(Prompt1$)
  1120.   Years1% = VAL(LEFT$(Et1$, 4))
  1121.   Days1% = VAL(MID$(Et1$, 6, 3))
  1122.   Hours1% = VAL(MID$(Et1$, 10, 2))
  1123.   Minutes1% = VAL(MID$(Et1$, 13, 2))
  1124.   Seconds1% = VAL(RIGHT$(Et1$, 2))
  1125.  
  1126.   Prompt2$ = "Select the second time -- The smaller time will be subtracted from the larger"
  1127.   Et2$ = GetElapsedTime$(Prompt2$)
  1128.   Years2% = VAL(LEFT$(Et2$, 4))
  1129.   Days2% = VAL(MID$(Et2$, 6, 3))
  1130.   Hours2% = VAL(MID$(Et2$, 10, 2))
  1131.   Minutes2% = VAL(MID$(Et2$, 13, 2))
  1132.   Seconds2% = VAL(RIGHT$(Et2$, 2))
  1133.  
  1134.   BT% = 1
  1135.   IF Years1% < Years2% THEN
  1136.     BT% = 2
  1137.   ELSEIF Years1% = Years2% AND Days1% < Days2% THEN BT% = 2
  1138.   ELSEIF Years1% = Years2% AND Days1% = Days2% AND Hours1% < Hours2% THEN BT% = 2
  1139.   ELSEIF Years1% = Years2% AND Days1% = Days2% AND Hours1% = Hours2% AND Minutes1% < Minutes2% THEN BT% = 2
  1140.   ELSEIF Years1% = Years2% AND Days1% = Days2% AND Hours1% = Hours2% AND Minutes1% = Minutes1% AND Seconds1% < Seconds2% THEN BT% = 2
  1141.   END IF
  1142.  
  1143.   ' first - second
  1144.   IF BT% = 1 THEN
  1145.     FirstYears% = Years1%: SecondYears% = Years2%
  1146.     FirstDays% = Days1%: SecondDays% = Days2%
  1147.     FirstHours% = Hours1%: SecondHours% = Hours2%
  1148.     FirstMinutes% = Minutes1%: SecondMinutes% = Minutes2%
  1149.     FirstSeconds% = Seconds1%: SecondSeconds% = Seconds2%
  1150.   ELSE
  1151.     FirstYears% = Years2%: SecondYears% = Years1%
  1152.     FirstDays% = Days2%: SecondDays% = Days1%
  1153.     FirstHours% = Hours2%: SecondHours% = Hours1%
  1154.     FirstMinutes% = Minutes2%: SecondMinutes% = Minutes1%
  1155.     FirstSeconds% = Seconds2%: SecondSeconds% = Seconds1%
  1156.   END IF
  1157.  
  1158.  
  1159.   SubtractedSeconds% = FirstSeconds% - SecondSeconds%
  1160.   IF SubtractedSeconds% < 0 THEN
  1161.     SubtractedSeconds% = SubtractedSeconds% + 60
  1162.     FirstMinutes% = FirstMinutes% - 1
  1163.   END IF
  1164.   SubtractedMinutes% = FirstMinutes% - SecondMinutes%
  1165.   IF SubtractedMinutes% < 0 THEN
  1166.     SubtractedMinutes% = SubtractedMinutes% + 60
  1167.     FirstHours% = FirstHours% - 1
  1168.   END IF
  1169.   SubtractedHours% = FirstHours% - SecondHours%
  1170.   IF SubtractedHours% < 0 THEN
  1171.     SubtractedHours% = SubtractedHours% + 24
  1172.     FirstDays% = FirstDays% - 1
  1173.   END IF
  1174.   SubtractedDays% = FirstDays% - SecondDays%
  1175.   IF SubtractedDays% < 0 THEN
  1176.     SubtractedDays% = SubtractedDays% + 365
  1177.     FirstYears% = FirstYears% - 1
  1178.   END IF
  1179.   SubtractedYears% = FirstYears% - SecondYears%
  1180.  
  1181.   CLS
  1182.   PRINT "SubtractedYears%: " + S$(SubtractedYears%)
  1183.   PRINT "SubtractedDays%: " + S$(SubtractedDays%)
  1184.   PRINT "SubtractedHours%: " + S$(SubtractedHours%)
  1185.   PRINT "SubtractedMinutes%: " + S$(SubtractedMinutes%)
  1186.   PRINT "SubtractedSeconds%: " + S$(SubtractedSeconds%)
  1187.   ll$ = P$
  1188.  
  1189.   FTWO$ = ElapsedTimeWrittenOut$(Et1$)
  1190.   STWO$ = ElapsedTimeWrittenOut$(Et2$)
  1191.   SubTWO$ = ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(SubtractedYears%, SubtractedDays%, SubtractedHours%, SubtractedMinutes%, SubtractedSeconds%))
  1192.  
  1193.   Result$ = FTWO$ + " minus " + STWO$ + " equals " + SubTWO$
  1194.   CLS: COLOR 14, 1: LOCATE 20, 1: PRINT LongCenter$(Result$, 50, TRUE%)
  1195.   ll$ = P$
  1196.  
  1197. SUB Multiply
  1198.   Prompt$ = "": Et$ = "": Years% = 0: Days% = 0: Hours% = 0: Minutes% = 0: Seconds% = 0: ETWO$ = "": x = 0
  1199.   Constant! = 0.0: ProductYears% = 0: ProductDays% = 0: ProductHours% = 0: ProductMinutes% = 0: ProductSeconds% = 0
  1200.   TMin% = 0: THr% = 0: Tsec% = 0: Tday% = 0: Tyr% = 0: Ans$ = ""
  1201.  
  1202.   Prompt$ = "Select a time to multiply"
  1203.   Et$ = GetElapsedTime$(Prompt$)
  1204.   Years% = VAL(LEFT$(Et$, 4))
  1205.   Days% = VAL(MID$(Et$, 6, 3))
  1206.   Hours% = VAL(MID$(Et$, 10, 2))
  1207.   Minutes% = VAL(MID$(Et$, 13, 2))
  1208.   Seconds% = VAL(MID$(Et$, 16, 2))
  1209.  
  1210.   COLOR 14, 1: CLS
  1211.   LOCATE 20, Center("Multiply")
  1212.   ETWO$ = ElapsedTimeWrittenOut$(Et$)
  1213.   LOCATE 22, Center(ETWO$): PRINT ETWO$
  1214.   x = Center("by what    ")
  1215.   LOCATE 25, x: INPUT "by what"; Constant!
  1216.  
  1217.   ProductSeconds% = RoundOff(Seconds% * Constant! / 100) * 100
  1218.   IF ProductSeconds% >= 60 THEN
  1219.     DO
  1220.       ProductSeconds% = ProductSeconds% - 60
  1221.       TMin% = TMin% + 1
  1222.     LOOP UNTIL ProductSeconds% < 60
  1223.   END IF
  1224.   ProductMinutes% = RoundOff(Minutes% * Constant! / 100) * 100 + TMin%
  1225.   IF ProductMinutes% >= 60 THEN
  1226.     DO
  1227.       ProductMinutes% = ProductMinutes% - 60
  1228.       THr% = THr% + 1
  1229.     LOOP UNTIL ProductMinutes% < 60
  1230.   END IF
  1231.   ProductHours% = RoundOff(Hours% * Constant! / 100) * 100 + THr%
  1232.   IF ProductHours% >= 24 THEN
  1233.     DO
  1234.       ProductHours% = ProductHours% - 24
  1235.       Tday% = Tday% + 1
  1236.     LOOP UNTIL ProductHours% < 24
  1237.   END IF
  1238.   ProductDays% = RoundOff(Days% * Constant! / 100) * 100 + Tday%
  1239.   IF ProductDays% >= 365 THEN
  1240.     ProductDays% = ProductDays% - 365
  1241.     Tyr% = Tyr% + 1
  1242.   END IF
  1243.   ProductYears% = RoundOff(Years% * Constant! / 100) * 100 + Tyr%
  1244.  
  1245.   CLS
  1246.   IF ProductYears% > 9999 THEN
  1247.     LOCATE 10: a$ = "": a$ = "May not display correctly": LOCATE , Center(a$): PRINT a$
  1248.   END IF
  1249.   LOCATE 20, Center(ElapsedTimeWrittenOut$(Et$)): PRINT ElapsedTimeWrittenOut$(Et$)
  1250.   Ans$ = "multiplied by " + S$(Constant!) + " equals": LOCATE 22, Center(Ans$): PRINT Ans$
  1251.   LOCATE 24, 1
  1252.   PRINT LongCenter(ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(ProductYears%, ProductDays%, ProductHours%, ProductMinutes%, ProductSeconds%)), 40, TRUE)
  1253.   ll$ = P$
  1254.  
  1255. FUNCTION RoundOff (Number!)
  1256.   DIM Rtn!, DifferentNumber!, Decimal!: Rtn = 0.0: DifferentNumber = 0.0: Decimal = 0.0
  1257.   Decimal = INT(Number * 1000) - (INT(Number * 100) * 10)
  1258.   DifferentNumber! = INT(Number! * 100)
  1259.   IF Decimal! >= 5 AND Decimal! <= 9 THEN
  1260.     DifferentNumber! = DifferentNumber! + 1
  1261.   ELSE
  1262.     DifferentNumber! = DifferentNumber!
  1263.   END IF
  1264.   Rtn = DifferentNumber! / 100
  1265.   RoundOff = Rtn!
  1266.  
  1267. FUNCTION GetElapsedTime$ (title$)
  1268.   DIM minOption, maxOption, haltAndDisplay, xPos, yPos, highlightedOption AS INTEGER
  1269.   DIM Years1, Days1, Hours1, Minutes1, Seconds1 AS INTEGER
  1270.   KeyThatWasHit% = 0: TimerStarted% = FALSE%: FirstTime% = 0: Increment% = 1: RecentTime% = 0: TimeDifference% = 0
  1271.  
  1272.   highlightedOption = 4: haltAndDisplay = TRUE
  1273.   minOption = 4: maxOption = 8
  1274.   DO
  1275.     userCommand$ = INKEY$
  1276.     IF haltAndDisplay = TRUE THEN
  1277.       COLOR 14, 1: CLS: yPos = 22: xPos = 10
  1278.       COLOR 15, 1
  1279.       titleCopy$ = title$
  1280.       IF LEN(titleCopy$) >= 60 THEN
  1281.         a$ = LongCenter(titleCopy$, 60, FALSE%)
  1282.         LOCATE 8, 1: PRINT a$
  1283.       ELSE
  1284.         LOCATE 8, Center(titleCopy$): PRINT title$
  1285.       END IF
  1286.       COLOR 12, 1
  1287.       Instructions$ = ""
  1288.       Instructions$ = "Use the arrow keys to select the desired elapsed time - Push [ENTER] to accept - Push "
  1289.       Instructions$ = Instructions$ + "Push [ESC] to reset - Push " + CHR$(34) + "X" + CHR$(34) + " to exit to the system"
  1290.       LOCATE yPos + 18, 1
  1291.       PRINT LongCenter$(Instructions$, 50, FALSE%)
  1292.  
  1293.       xPos = xPos + 16
  1294.  
  1295.       'Years
  1296.       LOCATE yPos - 5, xPos - 10
  1297.       IF highlightedOption = 4 THEN
  1298.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Years"
  1299.       LOCATE yPos - 2, xPos - 10: COLOR 14, 1:
  1300.       IF Years1 - 1 >= 0 THEN
  1301.       PRINT USING "#,###"; (Years1 - 1): ELSE PRINT "9,999": END IF
  1302.       LOCATE yPos: COLOR 10, 0: IF Years1 >= 0 AND Years1 < 10 THEN
  1303.         LOCATE , xPos - 6: PRINT S$(Years1)
  1304.       ELSEIF Years1 >= 10 AND Years1 < 100 THEN LOCATE , xPos - 7: PRINT S$(Years1)
  1305.       ELSEIF Years1 >= 100 AND Years1 < 1000 THEN LOCATE , xPos - 8: PRINT S$(Years1)
  1306.       ELSEIF Years1 >= 1000 AND Years1 < 10000 THEN LOCATE , xPos - 10: PRINT USING "#,###"; Years1
  1307.       ELSE PRINT "I hope I don't see this error": END IF
  1308.       LOCATE yPos + 2, xPos - 10: COLOR 14, 1: IF Years1 + 1 < 10000 THEN
  1309.       PRINT USING "#,###"; Years1 + 1: ELSE PRINT USING "#,###"; 0: END IF
  1310.  
  1311.       'Days
  1312.       LOCATE yPos - 5, xPos
  1313.       IF highlightedOption = 5 THEN
  1314.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Days"
  1315.       COLOR 14, 1: LOCATE yPos - 2, xPos: IF Days1 - 1 = -1 THEN
  1316.       PRINT "364": ELSE PRINT USING "###"; Days1 - 1: END IF
  1317.       COLOR 10, 0: LOCATE yPos: IF Days1 < 10 THEN
  1318.         LOCATE , xPos + 2: PRINT S$(Days1)
  1319.       ELSEIF Days1 < 100 THEN LOCATE , xPos + 1: PRINT S$(Days1)
  1320.       ELSE LOCATE , xPos: PRINT S$(Days1): END IF
  1321.       COLOR 14, 1: LOCATE yPos + 2, xPos + 0: IF Days1 + 1 < 365 THEN
  1322.       PRINT USING "###"; Days1 + 1: ELSE PRINT USING "###"; 0: END IF
  1323.  
  1324.       LOCATE yPos - 5, xPos + 9
  1325.       IF highlightedOption = 6 THEN
  1326.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Hours"
  1327.       COLOR 14, 1: LOCATE yPos - 2, xPos + 11: IF Hours1 - 1 >= 0 THEN
  1328.       PRINT S$(Hours1 - 1): ELSE PRINT "23": END IF
  1329.       LOCATE yPos, xPos + 11: COLOR 10, 0: PRINT S$(Hours1)
  1330.       LOCATE yPos + 2, xPos + 11: COLOR 14, 1: IF Hours1 + 1 <= 23 THEN
  1331.       PRINT S$(Hours1 + 1): ELSE PRINT "0": END IF
  1332.  
  1333.       LOCATE yPos - 5, xPos + 18
  1334.       IF highlightedOption = 7 THEN
  1335.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Minutes"
  1336.       COLOR 14, 1: LOCATE yPos - 2, xPos + 20: IF Minutes1 - 1 >= 0 THEN
  1337.       PRINT S$(Minutes1 - 1): ELSE PRINT "59": END IF
  1338.       LOCATE yPos, xPos + 20: COLOR 10, 0: PRINT S$(Minutes1)
  1339.       LOCATE yPos + 2, xPos + 20: COLOR 14, 1: IF Minutes1 + 1 < 60 THEN
  1340.       PRINT S$(Minutes1 + 1): ELSE PRINT "0": END IF
  1341.  
  1342.       LOCATE yPos - 5, xPos + 29
  1343.       IF highlightedOption = 8 THEN
  1344.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT "Seconds"
  1345.       COLOR 14, 1: LOCATE yPos - 2, xPos + 32: IF Seconds1 - 1 >= 0 THEN
  1346.       PRINT S$(Seconds1 - 1): ELSE PRINT "59": END IF
  1347.       LOCATE yPos, xPos + 32: COLOR 10, 0: PRINT S$(Seconds1)
  1348.       LOCATE yPos + 2, xPos + 32: COLOR 14, 1: IF Seconds1 + 1 <= 59 THEN
  1349.       PRINT S$(Seconds1 + 1): ELSE PRINT "0": END IF
  1350.  
  1351.       a$ = "": a$ = ElapsedTimeWrittenOut$(MakeElapsedTimeShort$(Years1, Days1, Hours1, Minutes1, Seconds1))
  1352.       LOCATE yPos + 12, Center(a$): PRINT a$
  1353.  
  1354.       haltAndDisplay = FALSE
  1355.     END IF
  1356.  
  1357.     SomeKey% = _KEYHIT
  1358.     IF SomeKey% = UpKeyHit% OR SomeKey% = DownKeyHit% THEN
  1359.       IF TimerStarted% = FALSE% THEN
  1360.         FirstTime% = TIMER
  1361.         TimerStarted% = TRUE%
  1362.       END IF
  1363.     END IF
  1364.     IF SomeKey% < 0 THEN
  1365.       FirstTime% = 0
  1366.       Increment% = 1
  1367.       TimeElapsed% = 0
  1368.       TimerStarted% = FALSE%
  1369.     END IF
  1370.     TimeElapsed% = ABS(TIMER - FirstTime%)
  1371.     IF TimeElapsed% = 2 THEN
  1372.       IF highlightedOption = 4 THEN Increment% = 5
  1373.       IF highlightedOption = 5 THEN Increment% = 3
  1374.       IF highlightedOption = 7 THEN Increment% = 2
  1375.       IF highlightedOption = 8 THEN incrment% = 2
  1376.     ELSEIF TimeElapsed% = 3 THEN
  1377.       IF highlightedOption = 4 THEN Increment% = 15
  1378.       IF highlightedOption = 5 THEN Increment% = 10
  1379.       IF highlightedOption = 7 THEN Increment% = 5
  1380.       IF highlightedOption = 8 THEN Increment% = 5
  1381.     ELSEIF TimeElapsed% = 4 THEN
  1382.       IF highlightedOption = 4 THEN Increment% = 40
  1383.       IF highlightedOption = 5 THEN Increment% = 15
  1384.     ELSEIF TimeElapsed% = 5 THEN Increment% = 70
  1385.     END IF
  1386.  
  1387.     SELECT CASE userCommand$
  1388.       CASE UpArrowKey$
  1389.         IF highlightedOption = 4 THEN
  1390.           Years1 = Years1 - Increment%
  1391.           IF Years1 <= -1 THEN Years1 = 9999
  1392.         ELSEIF highlightedOption = 5 THEN
  1393.           Days1 = Days1 - Increment%
  1394.           IF Days1 <= -1 THEN Days1 = 364
  1395.         ELSEIF highlightedOption = 6 THEN
  1396.           Hours1 = Hours1 - 1
  1397.           IF Hours1 = -1 THEN Hours1 = 23
  1398.         ELSEIF highlightedOption = 7 THEN
  1399.           Minutes1 = Minutes1 - Increment%
  1400.           IF Minutes1 <= -1 THEN Minutes1 = 59
  1401.         ELSEIF highlightedOption = 8 THEN
  1402.           Seconds1 = Seconds1 - Increment%
  1403.           IF Seconds1 <= -1 THEN Seconds1 = 59
  1404.         END IF
  1405.         haltAndDisplay = TRUE
  1406.       CASE DownArrowKey$
  1407.         IF highlightedOption = 4 THEN
  1408.           Years1 = Years1 + Increment%
  1409.           IF Years1 >= 10000 THEN Years1 = 0
  1410.         ELSEIF highlightedOption = 5 THEN
  1411.           Days1 = Days1 + Increment%
  1412.           IF Days1 >= 365 THEN Days1 = 0
  1413.         ELSEIF highlightedOption = 6 THEN
  1414.           Hours1 = Hours1 + 1
  1415.           IF Hours1 = 24 THEN Hours1 = 0
  1416.         ELSEIF highlightedOption = 7 THEN
  1417.           Minutes1 = Minutes1 + Increment%
  1418.           IF Minutes1 >= 60 THEN Minutes1 = 0
  1419.         ELSEIF highlightedOption = 8 THEN
  1420.           Seconds1 = Seconds1 + Increment%
  1421.           IF Seconds1 >= 60 THEN Seconds1 = 0
  1422.         END IF
  1423.         haltAndDisplay = TRUE
  1424.       CASE RightArrowKey$
  1425.         highlightedOption = highlightedOption + 1
  1426.         IF highlightedOption > maxOption THEN highlightedOption = minOption
  1427.         haltAndDisplay = TRUE
  1428.       CASE LeftArrowKey$
  1429.         highlightedOption = highlightedOption - 1
  1430.         IF highlightedOption < minOption THEN highlightedOption = maxOption
  1431.         haltAndDisplay = TRUE
  1432.       CASE CHR$(13), CHR$(32)
  1433.         Rtn$ = MakeElapsedTimeShort$(Years1, Days1, Hours1, Minutes1, Seconds1)
  1434.       CASE CHR$(27)
  1435.         montH = 1: daY = 1: year = 2022
  1436.         Years1 = 0: Days1 = 0: Hours1 = 0: Minutes1 = 0: Seconds1 = 0
  1437.         Years2 = 0: Days2 = 0: Hours2 = 0: Minutes2 = 0: Seconds2 = 0
  1438.         haltAndDisplay = TRUE
  1439.       CASE "X", "x"
  1440.         SYSTEM
  1441.     END SELECT
  1442.   LOOP UNTIL userCommand$ = CHR$(13) OR userCommand$ = CHR$(32)
  1443.  
  1444.   GetElapsedTime$ = Rtn$
  1445.  
  1446.  
  1447.  
  1448. FUNCTION MonthOrDayFromDaysPassedJan% (Days27%, Month1Day2%, Year27%)
  1449.   MODFDPJRtn% = 0: Month27% = 0: Leap% = 0
  1450.  
  1451.   IF Year27% MOD 4 = 0 THEN
  1452.   Leap% = 1: ELSE Leap% = 0: END IF
  1453.   SELECT CASE Days27%
  1454.     CASE 1 TO 31 'January
  1455.       Month27% = 1
  1456.       Days27% = Days27%
  1457.     CASE 32 TO 59 + Leap% 'February
  1458.       Month27% = 2
  1459.       Days27% = Days27% - 31
  1460.     CASE 60 + Leap% TO 90 + Leap% 'March
  1461.       Month27% = 3
  1462.       Days27% = Days27% - 59 - Leap%
  1463.     CASE 91 + Leap% TO 120 + Leap% 'april
  1464.       Month27% = 4
  1465.       Days27% = Days27% - 90 - Leap%
  1466.     CASE 121 + Leap% TO 151 + Leap% 'may
  1467.       Month27% = 5
  1468.       Days27% = Days27% - 120 - Leap%
  1469.     CASE 152 + Leap% TO 181 + Leap%
  1470.       Month27% = 6
  1471.       Days27% = Days27% - 150 - Leap%
  1472.     CASE 182 + Leap% TO 212 + Leap%
  1473.       Month27% = 7
  1474.       Days27% = Days27% - 180 - Leap%
  1475.     CASE 213 + Leap% TO 243 + Leap%
  1476.       Month27% = 8
  1477.       Days27% = Days27% - 212 - Leap%
  1478.     CASE 244 + Leap% TO 273 + Leap%
  1479.       Month27% = 9
  1480.       Days27% = Days27% - 243 - Leap%
  1481.     CASE 274 + Leap% TO 304 + Leap%
  1482.       Month27% = 10
  1483.       Days27% = Days27% - 273 - Leap%
  1484.     CASE 305 + Leap% TO 334 + Leap%
  1485.       Month27% = 11
  1486.       Days27% = Days27% - 304 - Leap%
  1487.     CASE 335 + Leap% TO 365 + Leap%
  1488.       Month27% = 12
  1489.       Days27% = Days27% - 334 - Leap%
  1490.   IF Month1Day2% = 1 THEN
  1491.     MODFDPJRtn% = Month27%
  1492.   ELSEIF Month1Day2% = 2 THEN
  1493.     MODFDPJRtn% = Days27%
  1494.   END IF
  1495.   MonthOrDayFromDaysPassedJan = MODFDPJRtn%
  1496.  
  1497. FUNCTION MonthWord$ (Month10%)
  1498.   MWRtn$ = ""
  1499.  
  1500.   SELECT CASE Month10%
  1501.     CASE 0 ' for the top value of the dial
  1502.       MWRtn$ = "December"
  1503.     CASE 1
  1504.       MWRtn$ = "January"
  1505.     CASE 2
  1506.       MWRtn$ = "February"
  1507.     CASE 3
  1508.       MWRtn$ = "March"
  1509.     CASE 4
  1510.       MWRtn$ = "April"
  1511.     CASE 5
  1512.       MWRtn$ = "May"
  1513.     CASE 6
  1514.       MWRtn$ = "June"
  1515.     CASE 7
  1516.       MWRtn$ = "July"
  1517.     CASE 8
  1518.       MWRtn$ = "August"
  1519.     CASE 9
  1520.       MWRtn$ = "September"
  1521.     CASE 10
  1522.       MWRtn$ = "October"
  1523.     CASE 11
  1524.       MWRtn$ = "November"
  1525.     CASE 12
  1526.       MWRtn$ = "December"
  1527.     CASE 13 'for the bottom value of the dial
  1528.       MWRtn$ = "January"
  1529.   MonthWord$ = MWRtn$
  1530.  
  1531. FUNCTION Suffix$ (DaySuffix%)
  1532.   SRtn$ = ""
  1533.   IF DaySuffix% = 1 OR DaySuffix% = 21 OR DaySuffix% = 31 THEN
  1534.     SRtn$ = "st"
  1535.   ELSEIF DaySuffix% = 2 OR DaySuffix% = 22 THEN SRtn$ = "nd"
  1536.   ELSEIF DaySuffix% = 3 OR DaySuffix% = 23 THEN SRtn$ = "rd"
  1537.   ELSE SRtn$ = "th": END IF
  1538.   Suffix$ = SRtn$
  1539.  
  1540. FUNCTION WrittenDate1Clock2Time3$ (AllFive$, Which%)
  1541.   WD1C2T3Rtn$ = "": Years8% = 0: Days8% = 0: Hours8% = 0: Minutes8% = 0: Seconds8% = 0: Month8% = 0
  1542.   AmPm8$ = "": LftNum8% = 0: RtNum8% = 0: LpYr% = 0
  1543.  
  1544.   Years8% = VAL(MID$(AllFive$, 1, 4))
  1545.   Days8% = VAL(MID$(AllFive$, 6, 3))
  1546.   Hours8% = VAL(MID$(AllFive$, 10, 2))
  1547.   Minutes8% = VAL(MID$(AllFive$, 13, 2))
  1548.   Seconds8% = VAL(MID$(AllFive$, 16, 2))
  1549.   SELECT CASE Which%
  1550.     CASE 1
  1551.       Month8% = MonthOrDayFromDaysPassedJan(Days8% - LpYr%, 1, Years8%)
  1552.       Days8% = MonthOrDayFromDaysPassedJan(Days8% - LpYr%, 2, Years8%)
  1553.       WD1C2T3Rtn$ = MonthWord$(Month8%)
  1554.       WD1C2T3Rtn$ = WD1C2T3Rtn$ + " " + S$(Days8%)
  1555.       WD1C2T3Rtn$ = WD1C2T3Rtn$ + Suffix$(Days8%) + ", " + S$(Years8%)
  1556.     CASE 2
  1557.       IF Hours8% = 0 THEN
  1558.         WD1C2T3Rtn$ = "12"
  1559.         AmPm8$ = "AM"
  1560.       ELSEIF Hours8% > 0 AND Hours8% < 12 THEN
  1561.         WD1C2T3Rtn$ = S$(Hours8%)
  1562.         AmPm8$ = "AM"
  1563.       ELSEIF Hours% = 12 THEN
  1564.         WD1C2T3Rtn$ = "12"
  1565.         AmPm8$ = "PM"
  1566.       ELSEIF Hours8% > 12 AND Hours8% < 24 THEN
  1567.         WD1C2T3Rtn$ = S$(Hours8% - 12)
  1568.         AmPm8$ = "PM"
  1569.       END IF
  1570.       WD1C2T3Rtn$ = WD1C2T3Rtn$ + ":" + S$(Minutes8%) + " " + AmPm8$ + " and " + S$(Seconds8%)
  1571.       IF Seconds8% <> 1 THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + "s"
  1572.     CASE 3
  1573.       IF Years8% <> 0 THEN
  1574.         IF Years8% >= 1000 AND Years8% <= 9999 THEN
  1575.           LftNum8% = INT(Years8% / 1000)
  1576.           WD1C2T3Rtn$ = S$(LftNum8%) + ","
  1577.           RtNum8% = Years8% - (LftNum8% * 1000)
  1578.           IF RtNum8% < 10 THEN
  1579.             WD1C2T3Rtn$ = WD1C2T3Rtn$ + "00"
  1580.           ELSEIF RtNum8% >= 10 AND RtNum8% < 100 THEN
  1581.             WD1C2T3Rtn$ = WD1C2T3Rtn$ + "0"
  1582.           END IF
  1583.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(RtNum8%)
  1584.         ELSE
  1585.           WD1C2T3Rtn$ = S$(Years8%)
  1586.         END IF
  1587.         WD1C2T3Rtn$ = WD1C2T3Rtn$ + " Year"
  1588.         IF Years% <> 1 THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + "s"
  1589.         IF Days8% <> 0 AND (Hours3% <> 0 OR Minutes8% <> 0 OR Seconds8% <> 0) THEN
  1590.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
  1591.         ELSEIF Days8% <> 0 AND (Hours8% = 0 AND Minutes8% = 0 AND Seconds8% = 0) THEN
  1592.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
  1593.         ELSEIF Hours8% <> 0 AND (Minutes8% <> 0 OR Seconds8% <> 0) THEN
  1594.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
  1595.         ELSEIF Hours8% <> 0 AND Minutes8% = 0 AND Seconds8% = 0 THEN
  1596.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
  1597.         ELSEIF Minutes8% <> 0 AND Seconds8% <> 0 THEN
  1598.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
  1599.         ELSEIF Minutes8% <> 0 XOR Seconds8% <> 0 THEN
  1600.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
  1601.         END IF
  1602.       END IF
  1603.       IF Days8% <> 0 THEN
  1604.         WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(Days8%) + " Day"
  1605.         IF Days8% <> 1 THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + "s"
  1606.         IF Hours8% <> 0 AND (Minutes8% <> 0 OR Seconds8% <> 0) THEN
  1607.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
  1608.         ELSEIF Hours8% <> 0 AND Minutes8% = 0 AND Seconds8% = 0 THEN
  1609.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
  1610.         ELSEIF Minutes8% <> 0 AND Seconds8% <> 0 THEN
  1611.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
  1612.         ELSEIF Minutes8% <> 0 XOR Seconds8% <> 0 THEN
  1613.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
  1614.         END IF
  1615.       END IF
  1616.       IF Hours8% <> 0 THEN
  1617.         WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(Hours8%) + " hour"
  1618.         IF Hours8% <> 1 THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + "s"
  1619.         IF Minutes8% <> 0 AND Seconds8% <> 0 THEN
  1620.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + ", "
  1621.         ELSEIF Minutes8% <> 0 XOR Seconds8% <> 0 THEN
  1622.           WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
  1623.         END IF
  1624.       END IF
  1625.       IF Minutes8% <> 0 THEN
  1626.         WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(Minutes8%) + " minute"
  1627.         IF Minutes8% <> 1 THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + "s"
  1628.         IF Seconds8% <> 0 THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + " and "
  1629.       END IF
  1630.       IF Seconds8% <> 0 THEN
  1631.         WD1C2T3Rtn$ = WD1C2T3Rtn$ + S$(Seconds8%) + " second"
  1632.         IF Seconds8% <> 1 THEN WD1C2T3Rtn$ = WD1C2T3Rtn$ + "s"
  1633.       END IF
  1634.       IF Years8% = 0 AND Days8% = 0 AND Hours8% = 0 AND Minutes8% = 0 AND Seconds8% = 0 THEN WD1C2T3Rtn$ = "Nothing"
  1635.   WrittenDate1Clock2Time3$ = WD1C2T3Rtn$
  1636.  
  1637.  
  1638. SUB Menu
  1639.   HaltAndDisplay% = 0: HighlightedOption% = 0: yPos% = 0: UserCommand$ = "": A$ = ""
  1640.   xPos% = 0: MaxOption% = 0: SelectedAnOption% = 0
  1641.  
  1642.   HaltAndDisplay% = TRUE%: HighlightedOption% = 1: yPos% = 13: MaxOption% = 7: SelectedAnOption% = FALSE%
  1643.   HighlightedOption% = 1
  1644.   HaltAndDisplay% = TRUE%
  1645.   yPos = 14
  1646.   DO
  1647.     UserCommand$ = INKEY$
  1648.     IF HaltAndDisplay% = TRUE% THEN
  1649.       COLOR 14, 1: CLS
  1650.       A$ = "Time Calculator Menu": xPos% = Center(A$)
  1651.       LOCATE yPos%, Center(A$): PRINT A$: LOCATE yPos% + 1, Center(A$)
  1652.       PRINT "---- ---------- ----"
  1653.  
  1654.       A$ = "": A$ = "1.) Find How Long From Now"
  1655.       LOCATE yPos% + 3, Center(A$): IF HighlightedOption% = 1 THEN
  1656.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1657.       A$ = "": A$ = "Until A Selected Time"
  1658.       LOCATE yPos% + 4, Center(A$): IF HighlightedOption% = 1 THEN
  1659.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1660.  
  1661.       A$ = "": A$ = "2.) Find How Long It Has Been Since"
  1662.       LOCATE yPos% + 6, Center(A$): IF HighlightedOption% = 2 THEN
  1663.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1664.       A$ = "": A$ = "A Selected Time Has Passed"
  1665.       LOCATE yPos% + 7, Center(A$): IF HighlightedOption% = 2 THEN
  1666.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1667.  
  1668.       A$ = "": A$ = "3.) Find The Date And Time It Will Be After"
  1669.       LOCATE yPos% + 9, Center(A$): IF HighlightedOption% = 3 THEN
  1670.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1671.       A$ = "": A$ = "A Selected Amount Of Time Has Passed"
  1672.       LOCATE yPos% + 10, Center(A$): IF HighlightedOption% = 3 THEN
  1673.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1674.  
  1675.       A$ = "": A$ = "4.) Add Two Elapsed Times"
  1676.       LOCATE yPos% + 12, Center(A$): IF HighlightedOption% = 4 THEN
  1677.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1678.  
  1679.       A$ = "": A$ = "5.) Subtract One Elapsed Time From Another One"
  1680.       LOCATE yPos% + 14, Center(A$): IF HighlightedOption% = 5 THEN
  1681.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1682.  
  1683.       A$ = "": A$ = "6.) Multiply An Elapsed Time By A Constant"
  1684.       LOCATE yPos% + 16, Center(A$): IF HighlightedOption% = 6 THEN
  1685.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1686.  
  1687.       A$ = "": A$ = "7.) Exit"
  1688.       LOCATE 45, Center(A$): IF HighlightedOption% = MaxOption% THEN
  1689.       COLOR 10, 0: ELSE COLOR 14, 1: END IF: PRINT A$
  1690.  
  1691.       HaltAndDisplay% = FALSE%
  1692.     END IF
  1693.  
  1694.     SELECT CASE UserCommand$
  1695.       CASE UpArrowKey$, LeftArrowKey$
  1696.         HighlightedOption% = HighlightedOption% - 1
  1697.         IF HighlightedOption% = 0 THEN HighlightedOption% = MaxOption%
  1698.         HaltAndDisplay% = TRUE%
  1699.       CASE DownArrowKey$, RightArrowKey$
  1700.         HighlightedOption% = HighlightedOption% + 1
  1701.         IF HighlightedOption% > MaxOption% THEN HighlightedOption% = 1
  1702.         HaltAndDisplay% = TRUE%
  1703.       CASE CHR$(13)
  1704.         SelectedAnOption% = TRUE%
  1705.       CASE "1", "2", "3", "4", "5", "6"
  1706.         HighlightedOption% = VAL(UserCommand$)
  1707.         SelectedAnOption% = TRUE%
  1708.     END SELECT
  1709.     IF SelectedAnOption% = TRUE THEN
  1710.       SELECT CASE HighlightedOption%
  1711.         CASE 1
  1712.           CALL FromNowUntil
  1713.           SelectedAnOption% = FALSE%
  1714.           HaltAndDisplay% = TRUE%
  1715.         CASE 2
  1716.           CALL HowLongSince
  1717.           SelectedAnOption% = FALSE%
  1718.           HaltAndDisplay% = TRUE%
  1719.         CASE 3
  1720.           CALL WhatDateAfterElapsedTime
  1721.           SelectedAnOption% = FALSE%
  1722.           HaltAndDisplay% = TRUE%
  1723.         CASE 4
  1724.           CALL AddElapsedTimes
  1725.           SelectedAnOption% = FALSE%
  1726.           HaltAndDisplay% = TRUE%
  1727.         CASE 5
  1728.           CALL SubtractElapsedTimes
  1729.           SelectedAnOption% = FALSE%
  1730.           HaltAndDisplay% = TRUE%
  1731.         CASE 6
  1732.           CALL Multiply
  1733.           SelectedAnOption% = FALSE%
  1734.           HaltAndDisplay% = TRUE%
  1735.       END SELECT
  1736.  
  1737.     END IF
  1738.   LOOP UNTIL UserCommand$ = CHR$(27) OR UserCommand$ = S$(MaxOption%)
  1739.  
  1740.  
  1741. FUNCTION Center% (Text$): Center% = INT((80 - LEN(Text$)) / 2): END FUNCTION
  1742. FUNCTION S$ (Number!): S$ = LTRIM$(STR$(Number!)): END FUNCTION
  1743.   pause$ = INPUT$(1): IF pause$ = CHR$(27) THEN END
  1744. P$ = pause$: END FUNCTION
  1745.  
Pages: 1 2 [3] 4 5 ... 10