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!
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.
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:
FOR n=VAL(MID$(TIME$,5,2)) TO 2 STEP -1
PROCcalday_change(-1)
NEXT n
DEF PROCcalday_change(nd)
calday%=calday%+nd
IF calday%<1 calday%=7
IF calday%>7 calday%=1
ENDPROC
I would *assume* that the problem is that PROCcalday_change gets
called the same number of times whether VAL(MID$(TIME$,5,2)) is 01
or 02, since the FOR loop isn't being allowed to go below 2,
but I don't see why that causes the value of calday% to
(apparently) be one integer smaller than it ought to be if TIME$
contains 01.
The routine that is printing the numbers from 1 to
(no_of_days_in_month) puts day 1 in the wrong column when the value
of calday% is wrong, too:
FOR n=1 TO monthd(calmonth%)
PROCset_icon_string(calendar%,(16+calday%+n),STR$(n))
NEXT n
But if I experimentally alter the FOR loop to go to 1 STEP -1 that
makes everything go haywire, so there is clearly a good reason for
this odd constraint!
In article <483b6a115a.harriet@bazleyfamily.co.uk>,
Harriet Bazley <harriet@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.
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.
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:
FOR n=VAL(MID$(TIME$,5,2)) TO 2 STEP -1
PROCcalday_change(-1)
NEXT n
That looks wrong - it certainly introduces an anomaly when it is the
1st, as calday% is set to the same number as for 2nd.
DEF PROCcalday_change(nd)
calday%=calday%+nd
IF calday%<1 calday%=7
IF calday%>7 calday%=1
ENDPROC
I would *assume* that the problem is that PROCcalday_change gets
called the same number of times whether VAL(MID$(TIME$,5,2)) is 01
or 02, since the FOR loop isn't being allowed to go below 2,
Agreed!
but I don't see why that causes the value of calday% to
(apparently) be one integer smaller than it ought to be if TIME$
contains 01.
Agreed again.
The routine that is printing the numbers from 1 to
(no_of_days_in_month) puts day 1 in the wrong column when the value
of calday% is wrong, too:
FOR n=1 TO monthd(calmonth%)
PROCset_icon_string(calendar%,(16+calday%+n),STR$(n))
NEXT n
That is because calday% is wrong.
But if I experimentally alter the FOR loop to go to 1 STEP -1 that
makes everything go haywire, so there is clearly a good reason for
this odd constraint!
I think it should be 1 STEP -1, as that corrects calday%.
Then the two calls to PROCset_icon_colour should be changed from +16
to +17 which corrects the colours.
I think!
It would be much easier to use Territory_ConvertTimeToOrdinals !!
To me, the code doesn't look extremely efficient. For example, the redraw routine will never be called, as the window consists of icons only.
Anyhow, it seems that this small change may work, as far as I've tested it (admittedly, not very far):
date% = VAL(MID$(time$,5,2))
IF date% > 1 THEN
FOR n=date% TO 2 STEP -1
PROCcalday_change(-1)
NEXT n
ENDIF
I committed the cardinal sin of not saving a copy of the original before starting my tinkering about,
On 2 Aug 2022 as I do recall,
Paul Sprangers wrote:
Anyhow, it seems that this small change may work, as far as I've
tested it (admittedly, not very far):
date% = VAL(MID$(time$,5,2))
IF date% > 1 THEN
FOR n=date% TO 2 STEP -1
PROCcalday_change(-1)
NEXT n
ENDIF
I also noticed that while the window was open, the processor was being consumed by 60k+ Null Polls/sec ... easily solved by changing
SYS "Wimp_Poll",,b% TO r%
to
SYS "Wimp_Poll",1,b% TO r%
I would assign the arrays days$(), monthb$(), monthd$() and leapyrs()
by eg:
days$() = "","Sun","Mon","Tue","Wed","Thu","Fri","Sat"
rather than RESTORE & READ loops, but that is being picky!
On 3 Aug 2022 as I do recall,
Martin wrote:
[snip]
I also noticed that while the window was open, the processor was
being consumed by 60k+ Null Polls/sec ... easily solved by
changing
SYS "Wimp_Poll",,b% TO r%
to
SYS "Wimp_Poll",1,b% TO r%
Worth doing. I just wish we could get these improvements back
into the original distribution!
I would assign the arrays days$(), monthb$(), monthd$() and
leapyrs() by eg:
days$() = "","Sun","Mon","Tue","Wed","Thu","Fri","Sat"
rather than RESTORE & READ loops, but that is being picky!
I suspect that would have required a newer version of BASIC than
available when the program was written.
(I didn't know you could do that....)
days$() = "","Sun","Mon","Tue","Wed","Thu","Fri","Sat"
(I didn't know you could do that....)
In article <b9282f125a.harriet@bazleyfamily.co.uk>,
Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
On 3 Aug 2022 as I do recall,
Martin wrote:
I also noticed that while the window was open, the processor was
being consumed by 60k+ Null Polls/sec ... easily solved by
changing
SYS "Wimp_Poll",,b% TO r%
to
SYS "Wimp_Poll",1,b% TO r%
Worth doing. I just wish we could get these improvements back
into the original distribution!
I fear any support has vanished a long time ago :-((
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 486 |
Nodes: | 16 (2 / 14) |
Uptime: | 137:47:08 |
Calls: | 9,657 |
Calls today: | 5 |
Files: | 13,707 |
Messages: | 6,167,142 |