Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 05/25/23 in all areas

  1. David Heffernan

    Use case or if else ?

    It would also be better to write a function that took the string, and returned the method to be called, to be held in a variable of procedural type. You could then have a single call to the procedure where you passed the arguments. It's very repetitious to pass the same 4 arguments to 14 separate methods.
  2. Remy Lebeau

    File Search

    If the root path already has a '\' on the end of it, you would be adding another '\' unnecessarily. Better to use IncludeTrailingPathDelimiter() instead, eg: LContinue := FindFirst(IncludeTrailingPathDelimiter(AFolderRoot) + APatternToSearch, faAnyFile, LSearchRecord) = 0; That comparison wont work correctly if the file name begins with any character that is lexicographically less-than '.' (a few of them are reserved, but many of them are not), namely: ! # $ % & ' ( ) + , - You need to check for '.' and '..' specifically instead, eg: if (LSearchRecord.Name = '.') or (LSearchRecord.Name = '..') then
  3. Brandon Staggs

    Problems with Delphi class structure / visibility

    The uses clause is not for classes, it's for units. The only "visibility" issue with regard to CLASSES defined in UNITS is what you put in INTERFACE vs IMPLEMENTATION. But since you are refusing to post ACTUAL CODE (nothing you have posted would compile, so it can't be ACTUAL CODE), there is little anyone here can do to help you understand.
  4. David Heffernan

    Problems with Delphi class structure / visibility

    It's possible to write poor code in any language.
  5. programmerdelphi2k

    Using inline variables inside loops

    firstly, I think that not right way to do it, but, as the var is allocated on stack, and the var-life is "short"! then, the next round, var will "dead", and create a new var on memory same address (if not used yet)!
  6. Anders Melander

    Optimization On or Off ?

    I'm surprised that something like ERP would benefit much from that. Do you have any numbers? Apart from that, like David, I have good experience with madExcept: No problems with optimization being on.
  7. shineworld

    Use case or if else ?

    In this case, a "key":@method hash list (GpStringHash from Primoz Gabrijelcic) could be a practicable solution ? I've used often...
  8. David Heffernan

    Use case or if else ?

    Why perform 7 comparisons, on average, when you can perform 14 every time?
  9. Fr0sT.Brutal

    set of object instances

    https://en.wikipedia.org/wiki/Set_(abstract_data_type)
  10. The hack with the @ operator works only in Win32, but Win64 has different calling conventions. Use a global function for the Sort method (matching the signature) instead of a local one (which does not).
  11. programmerdelphi2k

    Problems with Delphi class structure / visibility

    the key-words is: "instances-of-classes" when you define the structure of a class, in fact, you are just defining a "layout" of future objects that will be created in memory. To take advantage of this structure, you need to create the object in memory. Or simply "instantiate the object"! For this reason, it is not possible to perform any actions on the object without first creating it!
  12. Brandon Staggs

    Problems with Delphi class structure / visibility

    Delph is a strongly-typed language with well-defined and understood private, protected, and public clauses of classes. Other than getting used to the "friend class" behavior of classes defined in the same unit, I can't imagine what is so mysterious about it. My guess is that you are confused due to the "friend class" behavior you have seen in some work and didn't realize what was happening. You can certainly come across code that is "impenetrable to anyone other than the original developer," but that has little to do with Delphi, at least not in the areas you have expressed frustration over in this thread.
  13. programmerdelphi2k

    Problems with Delphi class structure / visibility

    @Willicious try this sample about class Scope that I did a long time ago... Class_Scope_Visibility.7z
  14. programmerdelphi2k

    Problems with Delphi class structure / visibility

    @Willicious I think your dissatisfaction is leading you to discuss a rhetoric that has existed as long as programming has existed! As for your dissatisfaction with your class, I think it only proves that it is not consistent and has been wrongly constructed, and possibly being misunderstood by you! Better rethink your code! As for using everything anywhere, then give up on object-oriented programming languages, or close to it. Better go back to "Basic for MSX"... lots of bits and bytes, no predefined structure, go forward or backward as you wish! And at the end, save your code on cassette tapes! If you want, try to post your code here or in some repository that, surely, someone will be able to give you a hand!
  15. programmerdelphi2k

    Problems with Delphi class structure / visibility

    for sure, BUT when you dont "declare" the objects/var/procedure/etc.. you DONT BE! right? then, for this, you NEED declare all that you need use!
  16. chkaufmann

    Problems with Delphi class structure / visibility

    private and protected are "friends" for classes within the same unit. If you don't want that, use "strict private" and "strict protected". For your second problem, you should provide an example. It is not clear to me what doesn't work. And by the way: When you write questions like this in a forum where most of the answers come from volunteers, you probably end up on the ignore list of many of them. Regards Christian
  17. Brandon Staggs

    Use case or if else ?

    What I meant was, if I have this: if SameStr(Val, 'kirk') then HandleKirk else if SameStr(Val, 'picard') then HandlePicard else if SameStr(Val, 'sisko') then HandleSisko; If I am not likely to add any more captains, there is no reason to optimize this with procedure registration and any kind of array or dictionary. But if Paramount keeps churning out garbage with new captains, at some point this is going to get long enough that if it is called in a loop, I will want to make the procedure lookup more optimal than a string if if-then-elses. For only three values, there is no advantage to registering these functions, because it is readable and there is no performance to be gained. But at some point performance will take a hit. I was curious what a general rule of thumb is for that. I realize it is a broad, general question of "feeling" that would be downvoted on SO. :-)
  18. dummzeuch

    Optimization On or Off ?

    None of configurations create a map file by default.
  19. dwrbudr

    VCL Styles - Font Change (editing vsf style file)

    You should look in the Fonts section of Bitmap Style Designer, probably changing Fonts->WindowTextNormal will do the job.
  20. It's not TList<T> from System.Generics.Collections. It's the age-old TList from System.Classes. Straight from the documentation: System.Classes.TList.Sort - RAD Studio API Documentation (embarcadero.com)
  21. mvanrijnen

    File Search

    Why not use (in unit System.IOUtils), TDirectory.GetFiles(), see: System.IOUtils.TDirectory.GetFiles - RAD Studio API Documentation (embarcadero.com)
  22. David Heffernan

    set of object instances

    What you've described is a set. So that's why he keeps thinking of it as a set.
×