Jump to content

corneliusdavid

Members
  • Content Count

    409
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by corneliusdavid


  1. 1 minute ago, Dany Marmur said:

    how do you sleep at night when you cannot se the code

    This seems a little harsh. I use a lot of code that others have written and which I cannot see (or haven't looked at). I sleep just fine at night. I don't have time to personally look at and test everyone else's code but trust that it works as described. Of course, it's wise to test the finished product that uses unseen code modules to make sure the end result is what you're after.

     

    In this case, there's a specific problem for which an answer is being sought and being able to see what the components do by looking at the code could help but will it actually take less time tracing through thousands of lines of unfamiliar classes than it would to post a question on a forum?


  2. 30 minutes ago, dummzeuch said:

    There is the GExperts Code Proofreader expert which supposedly can correct typos like Heigth to Height etc.

    This is a great feature--I've used it both for proof-reading and for simple keyboard macro expansion (before Live Templates).

     

    3 hours ago, Tommi Prami said:

    I almost always missspell Lenhgt and Widht

    Using GExpert's Code Proofreader or Delphi's Live Templates, you can either auto-correct your most common misspellings or set up small keyboard macros to do the typing for you. For example, instead of typing "length" you could type "lg" and it would be expanded to "length" for you.  I misspell "string" a lot and so set up "sg" to type it out for me.

     

    This productivity trick saves a lot of time--I blogged about it a few months ago: https://corneliusconcepts.tech/delphi-productivity-tips-live-templates

    • Like 1

  3. 17 hours ago, David Heffernan said:

    That just tells you about this one piece of code and whichever compilers you happened to use. It doesn't prove a rule. 

    True. Somewhere back in time, I thought I had heard or read this and well, it made sense (to me) and a quick test of this one particular case in one particular version of Delphi confirmed my thinking but you're right, it certainly does not prove a rule. The much, MUCH better way is to just avoid writing obscure code in the first place. :classic_cool:

    • Like 1

  4. 3 hours ago, kaarigar said:

    This code shows async dialog. I need sync or modal dialog on android

    Uh, both the subject of this thread and your original question specifically asked for async dialogs:

    On 1/15/2022 at 11:42 AM, kaarigar said:

    Is there any way to have async dialogs on android platform?

    So I guess I'll let someone else try and answer your question.

    • Like 2

  5. 25 minutes ago, David Heffernan said:

    In an expression like a + b, a and b can be evaluated in either order.

    Yes, for simple variables but I'm pretty sure that functions have to be evaluated first. I ran a simple test of OP's code and verified before I answered. I ran it in Delphi 10.4; perhaps an earlier version of Delphi (or a compiler directive?) would change that.

     

    29 minutes ago, David Heffernan said:

    If you want to make your code well defined then you need to evaluate the function on one statement, and then perform the addition in another.

    I totally agree with this. 


  6. 2 minutes ago, David Schwartz said:

    I found it easier to just lay them down algorithmically rather than use any of the fancy flowgrid/panel/etc options. 

    I'm going to take a guess that it's easier because you're used to writing the code to do that. I'll bet, with a bit of research and experimentation, you could save yourself a lot of code using a "fancy flowgrid/panel/etc". These components make laying things out not only very quick and easy but also work with fluid form sizes (like mobile devices) a breeze when things change at runtime. Of course, desktop apps often have a rigid layout so it's not critical, but since this discussion is based on FireMonkey, we can't assume it isn't mobile.


  7. Whether to build the controls dynamically depends on your project--if you have a lot of buttons or want them added dynamically based on configuration or options or something, then that's very doable. It's a little easier to see how everything will fit and look if you do it at design-time, though.

     

    For activating when you hover over a button, use the MouseEnter and MouseLeave events.


  8. For a "grid" of buttons, you don't need to use a grid control--the first thing I thought you meant when I was reading this. Instead just place the buttons in a grid-like manner on a form or panel. I would highly recommend using a FlowLayout to provide automatic arrangement of the buttons to accommodate both landscape and portrait views of the app (if you're aiming to put this on small devices). Watch this Embarcadero video that demonstrates the concept.


  9. 7 hours ago, Fr0sT.Brutal said:

    it took me some time to realize the difference between "Line break" (aka "New line" or "End of line" sign) and "CRLF" which are the same on Windows but not on other OS's. EOL is OS-dependent and CRLF is constant.

    This is why I use the constant sLineBreak as defined in the System unit.


  10. On 1/3/2022 at 9:12 AM, David Heffernan said:

    It still doesn't make any sense to me why you wouldn't just use TStopwatch. 

    I agree. Since I discovered TStopWatch (in the RTL's Diagnostics unit), I use it exclusively for any timing as it's so simple. It's been in Delphi at least back to XE if not before. No use writing your own timing routines anymore.

    • Thanks 1

  11. There could be a whole bunch of reasons but we'd just be shooting in the dark unless you show some code (and possibly surrounding contextual code). Did you do a build/compile without debugging and then look to see if there's a little dot to the left of the code line in the editor which indicates it's a line that will be executed?  Have you tried breaking at other points in the code? Does the app actually run?


  12. 10 hours ago, Joseph MItzen said:

    What, you don't want to be like me and walk out the door with nothing lined up a few weeks before the Great Recession hits?

    LOL! Yeah, I like to eat and keep a roof over my head, so I swallow my pride once in a while.

     

    10 hours ago, Joseph MItzen said:

    So that's some of what informed my initial response

    This is good insight. I like to give the benefit of the doubt, perhaps too much so. After writing a book that covered all the aspects of the IDE and supporting tools and various platforms, I have a greater appreciation for how much there really is to keep up; that's reinforced when I hear webinars about all the things being worked on and bugs addressed. (But then again, why are there so many bugs?) So hearing these stories do place this thread in better perspective.

     

    But I read so many complaints in these forums and well, I guess I feel there's just too much whining sometimes. All too often, employee programmers are caught in the middle between business people only concerned about the bottom line and the plight of the end user that has to use sub-par products. That's why I'm working for myself now--I got sick of not being allowed to upgrade products or redesign a library for better use, even if it has to push out other projects for a few weeks.

     

    And if a tool isn't working right for me, I switch tools. I guess that's kind of along the same principle of quitting if a job doesn't work out--but again, it's not feasible when you have thousands or millions of lines of code to deal with.

    • Like 1

  13. 15 minutes ago, Joseph MItzen said:

    They can quit and keep their integrity

    You make it sound so simple but that's seldom reality. I've had jobs where I've worked on fascinating projects and with great people but there will be one manager that promises things to too many customers and then has to make excuses for why stuff isn't done. When we get on the phone with customers, we're not allowed to talk about internal priorities or other reasons why something isn't done. It's quite frustrating but just walking out isn't always the best choice if there are no other jobs in the area or if other parts of the employment are good enough to keep you there. I was eventually able to leave that company but it took me a while to line up something else.


  14. 12 hours ago, toufik said:

    what 's the best way to encrypt a string .?,
    and to it password for example 

    You mention passwords (and then serial numbers). Instead of encrypting, do you just want to hash it and store the hash, which can't be decrypted? This is often done with passwords (or a serial number that is entered for verification) where you don't ever need to decrypt the stored value, just generate a hash each time it's entered and compare the entered hash to the stored hash.

    • Thanks 1

  15.  

    10 minutes ago, Tom F said:

    Is it safe to set a form's parent to nil, as in TForm.Create(nil)?

    Yes, I've implemented this technique many times over the years. For example, in a plugin where I don't have easy access to the main application form's handle or when I don't want a global form variable laying around for inadvertent use and just have a quick dialog form to show and destroy.

    12 minutes ago, Tom F said:

    Does a form inherit properties and behaviors from a parent that if we use nil are not inherited?

    Someone may correct me but as far as I know, it doesn't do any more than set the Owner property; then when the owner is being freed, its destructor checks to see if the Owner is nil and if not, frees it.

     

    So, if you assign it, then free it yourself, it'll try to be freed twice unless you set the Owner := nil manually. Conversely, if you don't assign it and don't free it, you'll create a memory leak. (I only mention these as things NOT to do to give more insight into what's happening.)


  16. Since it was created like this from Form1:

    11 minutes ago, Tom F said:

    TForm2.Create(Self);

    you don't need to explicitly free it--it will be freed when the owner form, Form1, is freed.

     

    Sometimes, however, you want/need to manage it yourself. For example:

    var
      Form3: TForm;
    begin
      Form3 := TForm3.Create(nil);
      try
        // do stuff...
      finally
        Form3.Free;
      end;

    This may be the case if you don't have a current form available.

×