Leaderboard
Popular Content
Showing content with the highest reputation on 05/25/23 in all areas
-
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.
-
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
-
Problems with Delphi class structure / visibility
Brandon Staggs replied to Willicious's topic in Delphi IDE and APIs
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. -
Problems with Delphi class structure / visibility
David Heffernan replied to Willicious's topic in Delphi IDE and APIs
It's possible to write poor code in any language. -
Using inline variables inside loops
programmerdelphi2k replied to havrlisan's topic in RTL and Delphi Object Pascal
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)! -
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.
-
In this case, a "key":@method hash list (GpStringHash from Primoz Gabrijelcic) could be a practicable solution ? I've used often...
-
Why perform 7 comparisons, on average, when you can perform 14 every time?
-
https://en.wikipedia.org/wiki/Set_(abstract_data_type)
-
Custom sort of a TList with object references (works in 32 bit, does not in 64 bit)
Uwe Raabe replied to Alexander Halser's topic in Algorithms, Data Structures and Class Design
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). -
Problems with Delphi class structure / visibility
programmerdelphi2k replied to Willicious's topic in Delphi IDE and APIs
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! -
Problems with Delphi class structure / visibility
Brandon Staggs replied to Willicious's topic in Delphi IDE and APIs
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. -
Problems with Delphi class structure / visibility
programmerdelphi2k replied to Willicious's topic in Delphi IDE and APIs
@Willicious try this sample about class Scope that I did a long time ago... Class_Scope_Visibility.7z -
Problems with Delphi class structure / visibility
programmerdelphi2k replied to Willicious's topic in Delphi IDE and APIs
@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! -
Problems with Delphi class structure / visibility
programmerdelphi2k replied to Willicious's topic in Delphi IDE and APIs
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! -
Problems with Delphi class structure / visibility
chkaufmann replied to Willicious's topic in Delphi IDE and APIs
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 -
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. :-)
-
None of configurations create a map file by default.
-
You should look in the Fonts section of Bitmap Style Designer, probably changing Fonts->WindowTextNormal will do the job.
-
Custom sort of a TList with object references (works in 32 bit, does not in 64 bit)
Der schöne Günther replied to Alexander Halser's topic in Algorithms, Data Structures and Class Design
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) -
Why not use (in unit System.IOUtils), TDirectory.GetFiles(), see: System.IOUtils.TDirectory.GetFiles - RAD Studio API Documentation (embarcadero.com)
-
set of object instances
David Heffernan replied to dummzeuch's topic in RTL and Delphi Object Pascal
What you've described is a set. So that's why he keeps thinking of it as a set.