Consider this code: procedure SplitAt(const _Input: string; _Position: integer; out _Head, _Tail: string); begin _Head := Copy(_Input, 1, _Position-1); _Tail := Copy(_Input, _Position); end; It's meant to split a given string into two parts at the given position. Nothing fancy, really, isn't it? Now, consider this call to the procedure above: var s1: string; s2: … Continue reading When const doesn’t mean const
Category: Delphi
Accessing the clipboard in a Firemonkey application
It just took me quite a while to find this information so I'll put it here for future reference. A Firemonkey application can not just access the clipboard, it needs to ask the platform whether it actually has one, then get the service interface and use that. uses Fmx.Platform; [...] function TryGetClipboardService(out _clp: IFMXClipboardService): boolean; … Continue reading Accessing the clipboard in a Firemonkey application
Updated dzEditorLineEndsFix
I have just updated dzEditorLineEndsFix to address a small problem: The tool can be too fast so the file is already gone when Delphi tries to access it. It now waits 200 ms after detecting the file creation before moving it. This should solve the issue. It's available for download from the dzEditorLineEndsFix page on … Continue reading Updated dzEditorLineEndsFix
Note to self: Do not use double quotes around field names
Note to self: If MS Access adds double quotes to field names in queries, do not use them! It won't complain about them (You'd wish it would), but it just won't work. So if you see something like: SELECT * FROM t_Mst_Tageserfassung WHERE ("TeMitarbeiter"=92) AND ("TeArbeitstag"=#12/24/2014#); Remove the quotes and it will start to work … Continue reading Note to self: Do not use double quotes around field names
Setting a default language with dxgettext
By default, if no translation for a language is available, dxgettext will not do any translation but use the strings as they are in the source code. Sometimes this is not desirable. e.g. Your customer does not understand the source language (e.g. your source language is not English but say German) You are using dxgettext … Continue reading Setting a default language with dxgettext
When CloseHandle does not close the handle
Today I spent several hours hunting down a problem with opening a COM port. Basically the program opens a COM port, writes some bytes to it, reads an answer and closes it again. This determines whether the expected device is connected to the COM port or not. If the answer is the expected one, so … Continue reading When CloseHandle does not close the handle
class as interface: Operator not applicable to this operand
Once in a while I run into this problem and every single time it takes me forever to remember the cause: Say, you have got an interface and a class implementing that interface: type IMyInterface = interface function asMyInterface: IMyInterface; end; type TMyClass = class(TInterfacedObject, IMyInterface) private function asMyInterface: IMyInterface; end; [...] function TMyClass.asMyInterface: IMyInterface; … Continue reading class as interface: Operator not applicable to this operand
Some changes to CustomContainerPack
Today I made some small changes to the CustomContainerPack. Apart from removing two with statements I changed the place where the wizard shows up in the File -> New -> Other dialog. Up to Delphi 7 it is still in the "New" category. For newer Delphi versions, it now shows up in the "Delphi Files" … Continue reading Some changes to CustomContainerPack
Custom Container Pack for Delphi XE2 to XE7
I just updated the Custom Container Pack sources to support Delphi XE2 to XE7. It was mostly a matter of creating the packages for the newer versions. I also had to adapt the registration code to changes in Delphi XE2. It now compiles and installs. I have not tested it extensively. We use it at … Continue reading Custom Container Pack for Delphi XE2 to XE7
dzlib compiles with all Delphi versions from 2007 to XE6
Today I spent some time to make dzlib compile with all Delphi versions from 2007 to XE6 (XE7 to come later). It didn't take too long since it already supported 2007, XE2 and XE6. It's interesting to see, how the RTL evolved between these versions. Some examples: The IsWhitespace function started out as a class … Continue reading dzlib compiles with all Delphi versions from 2007 to XE6