On 2 Aug 2022 as I do recall,
Martin wrote:
> In article <
483b6a115...@bazleyfamily.co.uk>,
> Harriet Bazley <
har...@bazleyfamily.co.uk> wrote:
> > On 2 Aug 2022 as I do recall,
> > Harriet Bazley wrote:
>
> > > Yesterday (i.e. before midnight on Monday) the !Calendar app
> > > inside Director
>
> > !Director.Apps.!Calendar
>
> > > was telling me that it was Sun 1st August. Now it has rolled
> > > over to correct itself to Tuesday 2nd August... while I was in
> > > the middle of trying to debug it, so we shall never know what was
> > > going on!
>
> I hate bugs which hide.
>
> It is much easier to debug if you add
> time$ = TIME$
> at the start, and replace all other TIME$ with time$.
> Then you can set time$ to any value for debugging, without messing
> with time itself.
That's a much better idea - I had to quit all my Internet stuff to avoid
problems with messed-up dates and Messenger expiring things every time I
changed TIME$....
>
> > There is definitely a bug in this app affecting *every* first day
> > of the month, which will always get displayed in the wrong column,
> > as can be demonstrated by forcibly setting the value of TIME$ just
> > before it gets checked. Put it back to 1st August, or 1st June,
> > or 1st July, and they all go wrong in the same manner.
I'm also more than a little surprised that no-one has ever run into this
particular bug since 1992, when the Calendar app was written!
>
> > It is too late at night and I can't get my head around why exactly
> > the program is doing what it is doing: the calculation is
> > (VAL(MID$(TIME$,5,2))+16+calday%) when calculating the icon handle
> > to highlight in red for 'today', where the icon numbers start at 18
> > for the first Sunday in a month, and where calday% starts off as
> > the index into an array of day names where Sunday is 1, and is then
> > cycled downwards according to the date value to form an arbitrary
> > offset pointer:
I think this is probably an exemplar of why it is a Bad Idea to reuse
your variables for other purposes (which I do myself all the time) - it
becomes extremely confusing as to what function the variable is actually
performing at any given point in the program.
Hmmm. That seems to correct the 1st August problem, but reliably
crashes with an abort on data transfer if I attempt to display August
2021 or May 2022 - presumably because a bad icon number is being passed
to FNstring_addr(window, icon%)
DEF FNstring_addr(window%,icon%)
REM returns address of icon's indirected text string
LOCAL c%
c%=b%+500
!c%=window%
c%!4=icon%
SYS "Wimp_GetIconState",,c%
=c%!28
Edit: yes, it crashes if icon% reaches 55, at which point c%!28 becomes
a rubbish value.
And icon% reaches 55 on months that start on a Sunday... although it
does *not* crash on November 2020. It just displays a completely blank
line for the first week, and starts on the following Sunday. Why?!!!
>
> It would be much easier to use Territory_ConvertTimeToOrdinals !!
>
I'm not sure it would help that much for the icon position/number
calculation, which is where the program is falling over (and which is
the part where I frankly haven't got my head around the logic).
--
Harriet Bazley == Loyaulte me lie ==
If it's not broken, don't fix it.