-
Content Count
3070 -
Joined
-
Last visited
-
Days Won
112
Everything posted by dummzeuch
-
Blogged : Delphi Package Manager RFC
dummzeuch replied to Vincent Parrett's topic in Tips / Blogs / Tutorials / Videos
I'm not sure that such a tool should support freepascal and Lazarus too. This would: Add a lot more complexity Get the maintainer / developer into unnecessary open vs. closed source discussions Would be a direct "competitor" to an already existing tool which would again cause endless discussions. I'm not a fan of tying it into Github, btw. -
Fast way to find points near a given point?
dummzeuch posted a topic in Algorithms, Data Structures and Class Design
I have a list of several thousand points with given X and Y coordinates (cartesian corrdinates in metres, stored as double) and of course additional properties. The list originally is sorted by one of the additional properties. I need to go through this list and for each point find others that are near this point, e.g. have a distance of less than 1 metre. This sounds like it should be a common problem and there should be an existing solution, but my Google skills have failed me. My approach would be: 1. Create two sorted lists, ListX sorted by X, ListY sorted by Y. 2. For each point find the points in ListX and ListY that are near the point's coordinates (example: Less than 1 metre in that direction.) 3. Take those points that are in both results and check their actual distance to my given point. -
Rather than hooking an event, which might already be hooked, you can create a custom TComponent descendant and set the main window as its parent. The main window will then destroy that component before it gets freed and you can intercept that to do whatever you need. Regarding chaining events, see here for my suggestion to play fair with other plugins.
-
Code block should be Delphi by default not HTML
dummzeuch replied to mael's topic in Community Management
Yes, it's an annoyance. Wasn't that already reported? I seem to remember a similar post. -
A google search found this: http://delphi.pjh2.de/articles/graphic/png.php#libpng and also, this http://www.libpng.org/pub/png/pngaptk.html which lists a few Delphi libraries with libpng support, but the links I tried were dead. and there is this: https://www.opengl24.de/header/libpng I haven't tried any of them.
-
I just fixed two (newly reported) bugs in GExperts: The Set Tab Order dialog no longer worked in Delphi 6, 7 and 2005. This was due to me adding AlignWithMargins (and the associated Margins property) to the dfm file. This property apparently was introduced in Delphi 2006. Again, this underlines what I mentioned several times: I do not use Delphi < 2007 for anything but testing and fixing bugs GExperts. That’s why glitches like this tend to slip by unnoticed. That’s why I would like people to volunteer for testing the various versions. But apparently nobody can be bothered. Fine by me, but you will have to live with the consequences. I don’t have a QA department. The extensions to the Uses Clause Manager caused several thousand (small) files to be created in the GExperts configuration directory. This directory is located under AppData\roaming\GExperts which means it will be copied when roaming profiles are enabledin a Windows domain. I didn’t know that anybody still uses roaming profiles since they are usually not worth the trouble, but apparently they are still being used. So I now moved that cache to AppData\local and also added a config option to disable caching altogether. https://blog.dummzeuch.de/2019/02/09/two-gexperts-bugs-fixed-14-to-go/
-
Complete Boolean Evaluation
dummzeuch posted a topic in Algorithms, Data Structures and Class Design
Has anybody ever enabled Complete Boolean Evaluation, and if yes, why? (see associated poll) Here is a use case (but I still would not do it this way but simply switch the conditions): -
How to pass an unknown record to a function as argument
dummzeuch replied to John Kouraklis's topic in RTL and Delphi Object Pascal
I missed the part about RTTI in the question. -
How to pass an unknown record to a function as argument
dummzeuch replied to John Kouraklis's topic in RTL and Delphi Object Pascal
function pass(var aRec): boolean; or function pass(const aRec): boolean; -
Guessing the decimal separator
dummzeuch posted a topic in Algorithms, Data Structures and Class Design
Sometimes I get files with text representations of numbers where it is not known what is used for the decimal separator. (I'm sure I am not the only one.) For this type of data, I have written the following function: function GuessDecimalSeparator(const _s: string): Char; var i: Integer; CommaCnt: Integer; begin CommaCnt := 0; Result := '.'; for i := 1 to Length(_s) do begin case _s[i] of '.': begin Result := '.'; end; ',': begin Inc(CommaCnt); Result := ','; end; end; end; if (Result = ',') and (CommaCnt = 1) then Exit; Result := '.'; end; It takes a string which is supposed to be a number in decimal representation, which can optionally contain thousands separators and a decimal separator. It then tries to guess, which one of '.' or ',' is the decimal separator. The algorithm is: Start at the beginning and count the occurrences of '.' and ','. The one that only occurs once is the decimal separator. If there is none, return '.' (because it does not matter). I can see the following problems with this approach: There are other possible decimal / thousands separators than '.' and ',' (personally I don't know any, but my experience is limited to European and American number formats). For strings in the form '1.000' (or '1,000') it assumes that the separator is the decimal separator. This could be wrong (That's why it's called GuessDecimalSeparator and not DetectDecimalSeparator.) For malformed strings (e.g. '1.00.00' or '1,00,00') the result is most likely wrong, but that's simply garbage in -> garbage out. I guess this could be improved. One possible improvement would be to not just process one number but many and check whether the results match. Any additional thoughts on this? -
How to switch condition position?
dummzeuch replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
No. You might want to look at Perl for that. 😉 -
fixed now (in the current sources).
-
appending to a dynamic array
dummzeuch posted a topic in Algorithms, Data Structures and Class Design
Given an array MyArr = array of TSomeRec Appending to that array means: Increase the length Set the values for the new record I have seen code like this: SetLength(MyArr, Length(MyArr) + 1); MyArr[High(MyArr)].SomeField := SomeValue; // and repeated for each field in TSomeRec This always triggers my bad smell sense because I would have coded it like this: var Len: integer; // [...] Len := Length(MyArr); SetLength(MyArr, Len + 1); MyArr[Len].SomeField := SomeValue; // and repeated for each field in TSomeRec Am I just too pedantic? (Please ignore for now that this might lead to memory fragmentation in both cases.) -
Hi Ian, first: Please start a new topic for requests like this. Or even better, file a feature request on SourceForge. I have no idea. I have not really understood what this does and how it works. When you file a feature request, make sure to add a short description of the functionality. twm
-
Conditional compilation for various Delphi versions
dummzeuch posted a topic in Tips / Blogs / Tutorials / Videos
If you are maintaining a library, component or plugin for various Delphi versions you will sooner or later hit a point where it becomes necessary to have different code for some of them. Some examples are: The constants faTemporary and faSymlink are only declared in Delphi 2009 and later, so you have to declare them yourself for older versions. Some Open Tools API function have bugs in some versions so you have to implement a workaround. Some classes or functions have been added to later versions of the RTL so you need to implement them yourself for older versions, but you don’t want to use these implementations for newer versions The traditional way of masking code for some Delphi versions is using the VERxxx symbols which the compiler defines, where xxx is the compiler version multiplied by 10. Note that the compiler versions started with Turbo Pascal, not with ... https://blog.dummzeuch.de/2018/12/02/conditional-compilation-for-various-delphi-versions/ -
Conditional compilation for various Delphi versions
dummzeuch replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
Your definition of "traditional" obviously is different from mine. Maybe I'm just older. In my blog post I actually continue: > An alternative is the {$IF } compiler directive which can test for arbitrary Boolean expressions [...] It was added to the Delphi compiler in Delphi 6, so it covers quite a few Delphi versions. < -
Guessing the decimal separator
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Me neither! Just pay me enough(*1) and I will do that for you - for one hour per week. *1: Enough means that that one hour per week must be enough to live on. -
Guessing the decimal separator
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Did you know that 86.64% of all statistics are made up? The remaining 53.42% have been tampered with. Seriously, is there any sense behind this number? -
Using dxgettext on Windows 10
dummzeuch replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
I just added a test for using gnugettext in a multithreaded environment: https://svn.code.sf.net/p/dxgettext/code/trunk/tests/MultithreadedResourceStringTest Could you please checkout this test and try to run it on your computer? If it's something that happens only there, maybe this simple test case might get some more information. There are two projects, one for Delphi 2007 and the other for Delphi 10.2. I haven't got Delphi 10.3 here to test, but loading and compiling the Delphi 10.2 project in Delphi 10.3 should work fine. Note that the project is meant to be run in the integrated debugger because in case of failure, the threads just raise an excpeption. These exceptions are only visible in the debugger. -
Guessing the decimal separator
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Define "fail". For German language settings it returns a comma, which is probably correct in most cases. Fail means that it might improperly return '.' on English language settings. If I knew the correct language settings for the input, I wouldn't have to guess the decimal separator. Yes, I am aware of that (as I said in the original post). In that case it would not matter. I could simply use '.' or ',' to convert it to a number and would get the correct result for either. -
Please file a bug report on SourceForge. And be more specific in it.
-
Guessing the decimal separator
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Because I don't know that it is an integer. I get a string that is supposed to be a number. I assume that the decimal separator is either a comma or a dot. I try to guess which one it is. One criterion: The decimal separator is only allowed once. There is none, as I already wrote in my original post: -
Guessing the decimal separator
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Will also fail on '1.000.000'. (Yes, I have read the comment, but that case is not as rare that I would accept the function to fail on it.) -
Is there a component that allows me to include proper digital signatures
dummzeuch replied to Dave Novo's topic in Delphi Third-Party
But you usually don't post credit card receipts on a sign post at a busy place. You just posted a picture of your signature on the internet ... -
Guessing the decimal separator
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
I started out with that approach, but: In '1.000.000' the decimal separator would definitely not be '.'. (or '1,000,000' it wouldn't be ',').