Like any syntax highlighter, it is not perfect (only a Delphi compiler driven highlighter would have a chance to be perfect), but it does a pretty good job and gets better over time.
Talking about Danny Thorpe: he also posted a nice hint on threading methods for ancient Delphi versions that equally applies to DLL exports in any Delphi version, even any programming environment.
Recently, I had to do some surgery in such a Pre-Delphi 6 application, and I was really happy to remember thisanswer: it instantly solved some process crashes, and the added logging allowed for investigating the actual cause.
Note that this tip isn’t just a good advice for old Delphi versions.
Even in younger Delphi versions, you have to watch methods that can be called from outside a regular Delphi context, for instance exported methods.
Heck, it applies to virtually any development environment: exceptions usually are very specific to that environment and should never cross a process boundary.
Summary
Take the approach below
for Execute methods in your own thread classes in Delphi 5 or earlier
Once every while, one of your StackOverflow answers gets an edit suggestion that is really valuable.
This case it was Edwin Yip who suggested to emphasize the difference between TStringBuilder and TStringList (adding characters versus lines).
Too bad that freshly 10k user Makoto showed he hates bold emphasis, intentional property casing and post signatures by removing the added value (there is so much emphasis he could remove on other answers to warrant at least a day time job).
I needed to modify some code that had been amended from the Delphi TParser class (which parses DFM files, but can be amended to other sources as well), so here are some links I found during my research:
Be sure to watch the presenter Stefan Eggermont (StackOverflow, Twitter, LinkedIn, GitHub, FOSDEM, website www.legacycode.nl) as this kind of analysis (that is also possible for other languages and tools) can highly speedup your work.
Even in unsuspiciously looking code, the wit statement can bite you, especially if you need to do refactoring and (because of that) introduce two names in the same scope.
Whilst upgrading the code to remove the Containers unit (its not supported on NextGen platforms, so I have to make things work with Generics.Collections instead, (bye bye D7 support for this code) and refactor a couple stupidities in my original design (they always creep in, don’t they) I ended up with two class members of the same name. The with block then looked OK but I was in fact not access the member I thought I was.
Every once in a while you have multiple threads or processes wanting to write a short message to the same log file. Append then will give you an I/O error 32 (ERROR_SHARING_VIOLATION), but the below small routine will sleep a bit while retrying a couple of times.
in $I- mode, you access the IOResult to obtain the results of those I/O operations
IOResult gets the result of the last failed operation (if any) or zero if none failed
IOResult clears the underlying storage to zero
$IFOPT checks for a certain state of a compiler flag
You can store the state of $OPT in a temporary conditional define
Note there are a few tables of codes you can get back through IOResult as basically you can get many GetLastError results in IOResult as well: Read the rest of this entry »