-
Content Count
3480 -
Joined
-
Last visited
-
Days Won
171
Posts posted by David Heffernan
-
-
On 4/26/2024 at 12:04 PM, Cristian Peța said:ZX-Spectrum BASIC was like an easier assembler where you use CALL and RET (Z80 assembler).
Speccie basic was a terrible language. The beeb had a much better variant.
-
18 minutes ago, RayTmsk said:What about topic question?
Well, knowing what you are doing in the setter functions is likely important to decide how to write them. You want to take copies? And do you have one member field for each array type?
Anyway, I'm also of the opinion that a branching generic method is little better than a series of overloads.
-
There are lots of different ways to do this depending on what the dll offers. Nobody can give you any steps without knowing how the dll exposes its functionality.
-
2 hours ago, RayTmsk said:procedure TDataField.SetAsGuidArray(SourceItems: TArray<TGuid>);
begin
DataType := ftArray;
FArrayItemType := ftGuid;
FDataArrayGuids := SourceItems;
end;
Are you sure this is right? It takes a reference to the array rather than a copy.
-
36 minutes ago, JonRobertson said:Different languages have different rules and syntax. Is that really an issue?
I see the "issue" as developers using the incorrect syntax for the language they are currently using.
If I toured Italy, I imagine my trip would be more enjoyable if I spoke Italian. Which I don't.
I mean I broadly agree. I was just trying to explain to Thomas what the post he was responding to actually said.
For me it's crazy that dynamic arrays are zero based but strings are one based. Obviously I can see how we got here.
-
1 hour ago, JonRobertson said:Should that matter? I started learning Pascal 35 years ago and C the following year. Not once have I written
c := (a < b) ? a : b;
or
if (a == b) { doSomething(); }
while writing Pascal code.
This is a strange post. The issue with multiple languages is the mix of zero based and one based indexing.
-
1 hour ago, dummzeuch said: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".
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.
-
1 hour ago, dummzeuch said:Oh, yes, I had totally forgotten about short strings. And also about that stupid idea of making strings zero based.
It would make far more sense for strings to be zero based. They are only one based because short strings stored their length in element 0.
-
22 minutes ago, dummzeuch said:My point is that you can't declare variables or types like this in Delphi.
You can for short strings
-
for var item in arr do
This is generally to be preferred, but sometimes you want the index as well as the item. In Python we write
for index, item in enumerate(arr): print(f"arr[{index}] = {item}")
The absence of such a feature, which also relies on tuple unpacking, makes such loops in Delphi less convenient. This is pretty much the only reason for still using classic for loops.
-
I use an EV code signing certificate
-
8 hours ago, Nigel Thomas said:Using Delphi D2007.
I'm trying to do the following:
type FileSig = record Offset: Integer; arrSig: array of byte; end; const sig1: FileSig = (Offset: 10; arrSig: array [0..2] of byte = ($00,$01,$02); )
But I can't: E2029 ')' expected but ',' found
In D10+ I can do:
const sig1: FileSig = (Offset: 10; arrSig: [$00,$01,$02]; )
Is there a way I can do similar in D2007?
No, this is not possible in Delphi 2007. You can declare typed constants for fixed length arrays, but not dynamic arrays.
- 1
-
Sorry, content removed, I'm talking nonsense.
-
Sorry, content remove, I'm talking nonsense
- 1
-
2 hours ago, Stefan Glienke said:Why are Delphi developers so obsessed with doing GUI
Isn't the reason that Delphi is good at building GUI apps, at least it was for vcl back in the day. And it's still good for pure Win32 apps.
- 2
-
Yeah, use threads
- 1
-
You need try/finally to avoid potential leaks. There are basically two main object creation patterns that you have to learn. You can't get far without them.
-
Can you link the documentation you refer to so that there is no ambiguity in the question
-
27 minutes ago, A.M. Hoornweg said:And many of these methods call each other, which complicates matters further because setfpcr/restorefpcr would have to support nesting.
That's easy to fix. You just make sure that they call internal methods only.
27 minutes ago, A.M. Hoornweg said:And multi-threading would make matters even more complicated.
Not really. You can store the FPCR to a local variable in the exported method.
The thing is, the change in Delphi 12 isn't actually causing any new issues. These issues always existed. It's just a consequence of the "design" of DLLs not making FPCR part of the ABI.
- 3
-
7 hours ago, msohn said:Now to get back to some real code, I'd love to hear your opinion on the following fragment (sorry, insert code popup again didn't work):
function MyFloatingPointAPI: Double; cdecl;
begin
try
Result:= ComplexCalculation;
except
on E: EInvalidOp do
Result:= NAN;
on E: EZeroDivide do
Result:= INF;
on E: Exception do
...log, handle, whatever
end;
end;If you properly document that NAN and INF are possible results of your API, this should work fine both with and without FP exceptions without introducing much of a performance hit, right?
One very obvious problem is that you need to write code like this everywhere. Not just at the top level. I stand by my advice before. Either:
1. Make FPCR part of the contract, or
2. Take control on entry, and restore on exit.
-
6 hours ago, msohn said:In the end, you should make your code work both ways and check floating point calculation results with IsNAN and IsInfinity, e.g.
try F:= <some floating point calculation> except on E: EInvalidOp do F:= NAN; on E: EZeroDivide do F:= INF; end; if IsNAN(F) then <handle InvalidOp> if IsInfinity(F) then <handle zero divide>
This is the worst advice I've seen in quite some time!!
-
DLLs should take charge of this. They should either make it part of their contract that the host sets the fp control state to a specific state. Or they should set it on entry, and restore it on exit. My DLL does the latter.
- 1
-
It's time to start using revision control
-
Why are you using ShellExecute. That's a deprecated function that used to be used to execute shell actions, but has been replaced by ShellExecuteEx. If you want to execute a specific program why aren't you using CreateProcess?
import C# Dll in delphi 10.4
in VCL
Posted
We still don't know anything about your dll. When I said that nobody can give you any step by step guides without knowledge of what the dll is, I stand by that. I mean, we could write you lots of hypotheticals. You've got one above. But how about you put some effort in and find out what this dll offers.