Sunday, March 12, 2023

More ideas for the 'blog manager' program

Recently, I've been forgetting to add 'This day in history' to a few blogs. The way that the procedure is written in the 'blog manager' program allows me only to find blogs for 'today', whatever 'today' might be. So for the past few days I've been thinking about adding the ability to find blogs for any given day of the year, not necessarily today. Fortunately, it was very easy to do this: I simply moved 99% of the code into an auxiliary procedure then called that procedure either with the date of 'today' or an arbitrary date.

procedure TMainForm.ShowHistory (adate: tdatetime); var y, m, d, instance: word; begin decodedate (adate, y, m, d); instance:= dm.NewInstance; with qInsert do begin sql.text:= 'insert into temp (id, instance) select entries.id, ' + inttostr (instance) + ' from entries ' + 'where extract (month from curdate) = :p1 ' + 'and extract (day from curdate) = :p2 '; parambyname ('p1').asinteger:= m; parambyname ('p2').asinteger:= d; execsql end; TShowEntries.create (instance, 'This day in history, ' + inttostr (d) + '/' + inttostr (m), true); end; procedure TMainForm.mnHistoryClick(Sender: TObject); begin ShowHistory (date); // i.e. today's date end; procedure TMainForm.mnSomeDayClick(Sender: TObject); var adate: tdatetime; begin with TChooseTagDates.create (nil) do try adate:= GetOneDate finally free end; if adate > 0 then ShowHistory (adate); end;

Not only was I forgetting to add the blog history, I discovered that I had neglected to log a few existing blogs. This happened to me a few times when I was entering the first 600 blogs manually. I was forced to renumber entries in two tables that fortunately the SQL manager allowed me to do. But it's a pain and the possibility of making mistakes - especially in the tags per entry table - is high. So today I thought that I would add the functionality to renumber automatically, should the need arise again (and it probably would). The main insight was to renumber 'in reverse'; if the maximum blog id number is 1589, then first 1589 should be renumbered to 1590, then 1588 to 1589, etc.  One has to input a starting number, or rather, a stopping number. This would be, of course, the first blog after the missing blog, so that a gap would be left for the missing blog. Renumbering the tags per entry table is performed in the same manner.

This blog is actually being written a day in advance (11/03/23) but now I can show the blog history for 12 March, thanks to the new functionality.



This day in history:

Blog # Date Title Tags
460 12/03/2012 Another example of Excel usage ERP, DBA, Excel
461 12/03/2012 Proposed doctorate DBA, Excel
556 12/03/2013 Pictures from a balcony (3) Personal
816 12/03/2015 This boy is on fire Programming, ERP
1016 12/03/2017 How to exclude rows from summation Priority tips
1297 12/03/2020 Apocalypse now Personal, Kibbutz, Weather, Covid-19
1380 12/03/2021 The continuing saga of saving unicode text - this time in the 'manager' program Delphi, Unicode
1479 12/03/2022 Another dismal Saturday Home recording

No comments: