OK. Anything else?
- Josef
issue-#63 fixes in StdStamps
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#63 fixes in StdStamps
the fixes have been merged into master.
Re: issue-#63 fixes in StdStamps
There is always something else ...Josef Templ wrote:OK. Anything else?
There was some discussion about more than one comment on a single date. I accepted your opinion that this could be relevant.
However it is possible to have both empty & used comments on the same date which I think is unintended. I think it would be better if the "new" option was not available if there
was already an empty comment with today's date.
But that said I now use StdStamps frequently, and think we have reached a very good (even if not perfect!) solution.
Regards
Robert
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#63 fixes in StdStamps
I agree, the intention was to support multiple commented entries per day.
If you show me the required changes, I can look at them and it should be possible to
get them into master.
Note: in case of an existing uncommented entry, the default Seq. Nr. is set to 1 already.
This makes it unlikely that a commented entry is added in addition to an existing uncommented entry.
But it is possible as you pointed out correctly.
- Josef
If you show me the required changes, I can look at them and it should be possible to
get them into master.
Note: in case of an existing uncommented entry, the default Seq. Nr. is set to 1 already.
This makes it unlikely that a commented entry is added in addition to an existing uncommented entry.
But it is possible as you pointed out correctly.
- Josef
Re: issue-#63 fixes in StdStamps
If fact I did it a few times accidently before I realised what was happening!Josef Templ wrote:This makes it unlikely ...
My first thought was to make it impossible to add a "new" comment when there was already an empty one.
I decide against this for several reason:
- It seemed difficult to code!
- It didn't repair the Stamps I have already "corrupted".
- There still remained the unlikely possibility of adding 2 actual comments, then later deleting one of them.
The proposal below is to alter the Internalize routine to purge these empty stamp entries.
I have currently left in my development / debug code; it is left justified, so is easy to remove.
To see the changes look for the variable "purge".
Code: Select all
PROCEDURE (v: StdView) Internalize (VAR rd: Stores.Reader);
VAR version: INTEGER; format: BYTE; k, purge, i, len,: INTEGER;
d: Dates.Date; t: Dates.Time;
f: Fmtrs.Fmtr;
BEGIN
v.Internalize^(rd);
IF ~rd.cancelled THEN
rd.ReadVersion(minVersion, maxVersion, version);
IF ~rd.cancelled THEN
IF version = origStampVersion THEN (* deal with old StdStamp format *)
(* would like to calculate fingerprint, but hosting model not available at this time *)
NEW(v.history, maxHistoryEntries);
v.history[0].fprint := 0;
v.history[0].snr := 1; v.nentries := 1;
rd.ReadXInt(d.year); rd.ReadXInt(d.month); rd.ReadXInt(d.day);
rd.ReadXInt(t.hour); rd.ReadXInt(t.minute); rd.ReadXInt(t.second);
rd.ReadByte(format); (* format not used anymore *)
v.history[0].date := Dates.Day(d);
v.history[0].time := t.minute + t.hour*64;
ELSE
f := Fmtrs.Log({});
IF version = noSnrVersion THEN NEW(v.history, maxHistoryEntries); rd.ReadInt(v.history[0].snr) END;
rd.ReadXInt(v.nentries);
f.IntLn(v.nentries, 4);
IF version > noSnrVersion THEN NEW(v.history, MAX(v.nentries, maxHistoryEntries)) END;
purge := 0;
FOR k := 0 TO v.nentries-1 DO
i := k - purge;
rd.ReadInt(v.history[i].fprint);
IF version > noSnrVersion THEN rd.ReadInt(v.history[i].snr)
ELSIF (* (version = noSnrVersion) & *) i > 0 THEN v.history[i].snr := v.history[i-1].snr - 1;
END;
rd.ReadInt(v.history[i].date);
rd.ReadXInt(v.history[i].time);
rd.ReadXInt(len);
IF len > 0 THEN
NEW(v.history[i].comment, len + 1);
IF version >= wideCommentVersion THEN
rd.ReadString(v.history[i].comment)
ELSE
rd.ReadXString(v.history[i].comment)
END
ELSE v.history[i].comment := NIL
END;
f.Int(i, 4);
f.Int(v.history[i].date,8);
f.IntStr(v.history[i].snr,8, ' ');
f.SetAsHex(BITS(v.history[i].fprint));
IF v.history[i].comment # NIL THEN f.Str(' ' + v.history[i].comment) END;
IF (i > 0) & (v.history[i].date = v.history[i-1].date) THEN
IF v.history[i-1].comment = NIL THEN
f.Str (' Previous comment empty');
v.history[i-1].comment := v.history[i].comment; INC(purge)
ELSIF v.history[i].comment = NIL THEN
f.Str (' This comment empty');
INC(purge)
END
END;
f.Ln
END;
DEC(v.nentries, purge);
IF version < wideCommentVersion THEN (* cleanup *)
i := v.nentries - 1;
WHILE (i > 0) & (v.history[i].date = 0) DO DEC(i); DEC(v.nentries) END
END
END
END
END
END Internalize;
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#63 fixes in StdStamps
Thanks, looks good to me. For the changes see
http://redmine.blackboxframework.org/pr ... 1ad9fa9b59
Let me know if everything is OK.
- Josef
http://redmine.blackboxframework.org/pr ... 1ad9fa9b59
Let me know if everything is OK.
- Josef
Re: issue-#63 fixes in StdStamps
Josef
Seems to be working fine - thanks.
Robert
Seems to be working fine - thanks.
Robert