Wednesday, November 06, 2024

More dopamine

Following on from yesterday's blog1 about a slightly more complicated SQL query replacing iteration over a cursor, today I implemented the required change. It was a bit different from the code that I described yesterday as I already had the tag count and so did not need to use count (*) and group by.

While I was working on this, a solution popped into my mind for a problem that occurs only with the first blog of each month. Adding the blog itself is no problem - normally I do this when the 'this day in history' form is showing - but I receive the contents of the blog after having done this; frequently 'tomorrow'. In order to show the blog, I request all the blogs from 'the beginning of the current month', but since there is only one blog, the contents of the blog will be displayed instead of a list of blogs. But as there is no content yet, nothing gets displayed. Of course, I could request all the blogs from 'the beginning of the previous month', but then I get all the blogs that I don't necessarily want to see.

The solution - as always - is simple when it's formed. A new form displays a listing of the files that are in the directory that the program accesses - normally only one file will be there - the new one. The program reads the file name that will include the full directory name as well as the 'htm' suffix (e.g. 'c:\db programs\data\Perceptions dopamine rush.htm) and extracts the name of the blog entry itself ('dopamine rush'). It then checks to see that there is a blog entry with that title but with no contents, and if so, the regular code for reading the contents is executed, which also deletes the file after it has been read.

Once I had finished writing this, of course a new idea revealed itself that was very simple to implement: display the contents of the new blog entry. This will happen every time that I import contents, not only with this special case.

Internal links
[1] 1850



This day in history:

Blog #Date TitleTags
5906/11/2006ShoppingVan der Graaf Generator, Peter Hammill, Musical instruments, Keyboard
21506/11/2009Eliza Carthy, "Red"Morse, Eliza Carthy
30106/11/2010Trains and mealsCooking, Trains, Slow cooker
108806/11/2017Forty years agoPersonal, Sandy Denny, Heron
118306/11/2018Intermediate thesis submitted!DBA
143606/11/2021Opening Word from a thread and displaying a fileProgramming, Delphi, Threads
155006/11/2022Appearances in my school's ChroniclesPersonal, Bristol Grammar School

No comments: