Jump to content

David Heffernan

Members
  • Content Count

    3740
  • Joined

  • Last visited

  • Days Won

    188

Posts posted by David Heffernan


  1. 53 minutes ago, Dave Novo said:

    So if I find a code snippet on the internet how to use the Format function to format floating point numbers and it recommends %8.2f, I should then read the source code of the format function in Delphi and make sure that I understand the entire method to ensure that the suggestion is correct.

    Why read the source code. You can read the documentation. Why wouldn't you want to be confident your code worked? Fine for throw away hobbyist programs. But for professional development you couldn't survive this way. Anyone in my team that tried this would be spoken to. 


  2. I was interested in the new AI chatbot that Emba are offering, which was announced in the webinar yesterday. It's at: https://www.embarcadero.com/radaicompanion

     

    The concept is that it is an AI bot that has been tweaked to target Emba products, Delphi, C++Builder etc. Anyway, after a recent question on SO I asked:

    Does the VCL have a TagObject property?

     

    The answer was a little disappointing:

     

    Yes, the VCL does have a TagObject property. It is available in the FMX.Types.TFmxObject class, which is part of the FireMonkey (FMX) framework, not the VCL. The TagObject property allows you to store any TObject value.

     

    I mean it gets there in the second sentence, but starting with Yes is poor. Classic AI people pleaser stuff!

     

    I then gave it some more recent SO questions and I have to say it did a good job.

     

    I'm quite interested in this concept though, and we've been working on something similar for our product because it's too niche for standard bots to know how to answer tricky questions.

    • Like 2

  3. Obviously Emba have trailed the new conditional operator (wish they'd call it this and not ternary, but whatever). But we've heard nothing else. So I was interested in the what's new webinar to see what else there would be. Turns out the reason nothing else has been talked about ahead of time is that there is nothing else. I didn't have high expectations, but they've managed to fall well short of them.

     

    Has anyone else seen anything worth talking about?


  4. 10 hours ago, Anders Melander said:

    Unless you are using it to scale graphics in real-time, or something like that, then it's a completely wasted effort. Also remember that pascal code can be inlined (avoiding the call overhead), while asm functions can't. I would replace the MulDiv with a simple expression; You likely don't need the 64-bit and overflow handling baked into MulDiv (which is a Windows API function, btw - not cheap).

    There's absolutely no scenario where the performance of these scaling functions could be important. It's just blind asm for the sake of it, premature optimisation 101


  5. 4 hours ago, HeartWare said:

    Then I just use Form1.Scale(8) to get a 96dpi 8-pixel scaled value at whatever scale factor the form (or rather, the monitor upon which the form is located) currently is at.

    You definitely don't want to be doing this when the VCL provides exactly this functionality.


  6. 1 minute ago, PeterPanettone said:

    Here are the CRC-32 hashes of some words (via System.Hash.THashCRC32):

     

    "one": 2053932785
    "two": 298486374
    "three": 1187371253
    "four": 2428593789
    "five": 1018350795

     

    These hashes are stored as keys in a TDictionary<Cardinal, TProc>, mapping each to an anonymous procedure that represents the "case" action (e.g., handling that specific string). At runtime, the input string is hashed, and the dictionary is used for quick lookup to invoke the corresponding action—mimicking a case statement efficiently. Since the hashes are collision-free for this set, no additional equality checks are needed, and the lookup is O(1).

    Sure you can write a dictionary that works with just these keys. But what is the point of a dictionary that works with these specific five keys? Have you got a real world example to hand? 


  7. 8 hours ago, dummzeuch said:

    The one thing that has annoyed me the most, is that you need an active subscription to even download an install bugfixes.

    Given that they never fix bugs in anything other than the very latest release, it's not that big a loss! 


  8. You didn't account for any font scaling. So if the user has a high dpi screen and a font scaling larger than 100% the your 26 and 8 won't be right. 

     

    Then again, because you didn't provide full code and details we are all guessing a bit. 

    • Like 1

  9. 3 hours ago, Freeeee said:

    code was from ? 2000,.  Worked then.

    There wasn't a reserved word "Result"

    so you  used the function name at the end of the code set equal to whatever variable 

    you were using to get the results. 

     Function doSomething: Integer;

    var X : integer

    begin 

        X := code to do something; 

    doSomething := X;

    end.

     

    What are you expecting anyone to do with this? 

    • Like 2

  10. Why are you expecting ANSI encodings to be of use? Why aren't you using Unicode, either UTF8 or UTF16. 

     

    I believe the function you call expects UTF8 which of course you are not passing. Then again I'm not sure why you picked on this function to make a string. 

    • Like 1
×