-
Content Count
2650 -
Joined
-
Last visited
-
Days Won
92
Posts posted by dummzeuch
-
-
You have listed chatGPT. Which version(s) were you using?
My own experience is that neither the free chatGPT nor Gemini are any good for producing Delphi code. I haven't tried any others.
- 1
-
2 hours ago, David Heffernan said:4 hours ago, dummzeuch said:In my opinion ...
Exit, Break and Continue are all good. No problem with them being used properly.
These local variables that are shared between local functions are very different because they tend to have larger scope that is harder to manage.
Somehow I expected your opinion to be different from mine...
-
1 hour ago, PeterBelow said:if you organize your program's tasks into classes then you can replace nested procedures with private methods of the class and either pass needed values as parameters or move the local variables used as private fields to the class declaration. IMO that gives a much cleaner and easier to understand design, and it keeps down the size of the methods.
Unless, of course you need a local type declaration that you don't want to be visible outside the unit. Such a type can be declared inside a procedure / method and used within that method and any nested procedure. To convert these nested procedures into methods, you will have to move the type declaration outside the main procedure/method. The same applies to constants.
-
3 hours ago, David Heffernan said:I always prefer to pass parameters because it makes it much clearer what the input/output of the function is.
Usually the so called convenience you refer to just leads to obfuscation.
In my opinion using this kind of variables falls into the same class as using break and continue in a loop. A little bit better than goto, a little bit worse than using exit.
I use it sparingly, but as I said: Sometimes it is just convenient.
-
I use them sometimes as a convenient way not to pass too many parameters. As far as I remember this comes with a performance penalty though.
I declare those shared variables at the top of the main procedure, above the nested procedures, and those that are not shared below the nested procedures.
- 5
-
... and save the changed desktop.
-
There is no such option.
-
fixed in revision #4248
-
11 minutes ago, David Heffernan said:It seems unlikely that somebody will write your program for you. Why don't you pay a programmer to do it?
ahem:
8 hours ago, Bahram Akhundov said:P.s i can pay extra for that!
just saying ...
-
You can only call methods and functions that you could also use in the unit being debugged. So make sure you include the unit that exports these in the uses clause.
-
1 hour ago, Lars Fosdal said:Quite a few sites still support RSS. Even those that don't announce their support, can have a living www.site.com/rss URL.
One of the enemies of RSS, are Paywalls.
Another one is "social" media.
-
Given that most sites don't offer feeds any more or have hidden them so most people won't know they exist, I don't think this will make much of a difference.
-
1 hour ago, sp0987 said:We need to modify all sysutils date time functions
Are you aware of the overloaded functions that take an additional TFormatSettings parameter?
-
Having read through this entire thread, I can only repeat what others already said: Changing the interface part of SysUtils requires recompiling nearly all other RTL and VCL units. That was already the case with Delphi 7.
I also agree that this is most likely not the best solution to your actual problem.
You said you needed a global variable in the interface section of SysUtils that multiple functions in that unit access. Which functions are you talking about and what is the purpose of this change? If you don't tell us, we can't suggest alternative solutions.
- 3
-
1 hour ago, Stalker4 said:As you advised, I compiled a new dll from the sources, but there was an error that I wrote about here and about which. I also wrote on “sourceforge” it is not corrected there. .
I'll be on vacation. Maybe I will find some time to look into this.
-
1 hour ago, Lajos Juhász said:Also until developers did not start to use multiple languages.
I have never ever confused Pascal Strings with C char* types. (And I have done quite a lot C programming at the beginning of my career, parallel to using Turbo Pascal and Visual Basic, before I chose Delphi as my main programming tool.)
-
3 hours ago, David Heffernan said:I don't disagree with that point. My point is that it was a bad idea in the first place to make strings 1 based.
Depends. Back then (in the 1970ies *1) it made a lot of sense to store strings that way. And when moving from Pascal to Delphi (>20 years later) and introducing longstrings (Delphi 2?) it already was a decision between keeping backwards compatibility to Pascal vs. being compatible with C.
Edit: (*1: I'm not sure when strings were introduced into Pascal: Was it an addition in Turbo Pascal (1986) or did they already exist in the original Pascal?)
-
Since Delphi is kind of a legacy programming language nowadays, backwards compatibility is very important. You don't want to throw away millions lines of proven code because they don't work any more, or even worse, because they are now buggy. So trying to change strings to be zero based was a bad idea, even if it was "just for mobile platforms".
- 3
-
1 hour ago, David Heffernan said:You can for short strings
Oh, yes, I had totally forgotten about short strings. And also about that stupid idea of making strings zero based.
-
5 hours ago, David Schwartz said:Aside from that, did you get anything from reading the post? (I don't have a compiler in my head, and I figured if I didn't show the declarations then someone would ding me on that.)
My point is that you can't declare variables or types like this in Delphi. This is C like syntax. In Delphi you have to give a low and a high limit for an array. So at least you don't have to guess.
-
8 hours ago, David Schwartz said:Considering Delphi:
Given this declaration: var ary[10] : char; str[10] : string;
[dcc32 Error] Project1.dpr(10): E2029 ',' or ':' expected but '[' found
[dcc32 Error] Project1.dpr(10): E2029 '(' expected but ';' found
[dcc32 Error] Project1.dpr(10): E2029 Expression expected but ';' found
-
1 hour ago, Cristian Peța said:If not multi threading then it can be.
We are talking about a DLL here, so your code might not be multithreaded, but the caller's still might be.
- 1
-
18 minutes ago, Cristian Peța said:procedure Foo; stdcall; begin SetFPCR; ... RestoreFPCR; end;
Do you think is so cumbersome to do this for every exposed function?
The SetFPCR and RestoreFPCR you need to write for yourself but only once.
And for convenience, use a global variable to store the state ... gd&r
- 2
-
I don't know whether it fits your definition of "good", but I have got:
https://sourceforge.net/p/dzlib/code/HEAD/tree/dzlib/trunk/src/u_dzIso8601.pas
and
https://sourceforge.net/p/dzlib/code/HEAD/tree/dzlib/trunk/src/u_dzDateUtils.pas
What do you think of "Local Global variables"
in RTL and Delphi Object Pascal
Posted
Yes. But only if they are simple types or (for complex types like large records or arrays) if they are passed by reference (var/const).
On the other hand: I doubt that this makes much of a difference for most programs.