-
Content Count
2538 -
Joined
-
Last visited
-
Days Won
145
Posts posted by Uwe Raabe
-
-
4 hours ago, DelphiUdIT said:But he's asking about C++
What makes you think so?
-
Or you try a total different approach described in this article: Dataset Enumerator Reloaded
The old repository can be found on GitHub: https://github.com/UweRaabe/DataSetEnumerator, although the current development happens in https://github.com/UweRaabe/CmonLib
Taking your code example from above:
var LTotal: Double; LField1: TField; LField2: TField; LField3: TField; LField4: TField; begin LField1 := Query.FieldByName('FIELD1'); LField2 := Query.FieldByName('FIELD1'); LField3 := Query.FieldByName('FIELD1'); LField4 := Query.FieldByName('FIELD1'); Query.First; while not Query.Eof do begin LTotal := LTotal + LField1.AsFloat; // More stuff done with local field variables... Query.Next; end;
a corresponding solution based on my unit could look like this:
uses Cmon.DataSetHelper; type [DBFields(mapAuto)] // make sure record fields are named similar to DB fields! TMyFields = record Field1: Double; Field2: Double; Field3: Double; Field4: Double; end; var LTotal: Double; begin LTotal := 0; for var rec in Query.Records<TMyFields> do begin LTotal := LTotal + rec.Field1; // More stuff done with rec end;
-
6 minutes ago, dummzeuch said:I my opinion Delphi 12 + Update 1 is a bit little more stable
There is no Delphi 12 Update 1 (yet), only Delphi 12 with Patch 1.
During times a common rule had established to wait for the first Update after an initial release before starting to use a Delphi version in production. That doesn't imply not to install and start using it - just not for production. JM2C
- 2
-
1 hour ago, Lars Fosdal said:Fields[ix] := Query.FieldByName(Names[ix]);
This will only change the TField array item, but not the local variable FieldX as expected.
A const or var array of TField is no replacement for a couple of var par: TField parameters. As soon as you construct that array parameter, the addresses of the local variables are gone, while their current content (which may be undefined here) is copied to the array item.
Perhaps this may be a better approach (didn't try as I am too lazy to create a fake dataset with these fields):
procedure ConnectFields(Query: TDataSet; const Fields: TArray<^TField>; const Names: TArray<string>); begin Assert(Length(Fields) = Length(Names), 'Number of fields and number of names must match'); for var ix := 0 to Length(Fields) - 1 do begin Fields[ix]^ := Query.FindField(Names[ix]); if not Assigned(Fields[ix]^) then raise Exception.Create(Format('Field %s not found.', [Names[ix]])); end; end; procedure Test; var Field1, Field2, Field3, Field4: TField; begin ConnectFields(Query, [ @Field1, @Field2, @Field3, @Field4], ['Field1', 'Field2', 'Field3', 'Field4']); ... end;
- 1
- 2
-
2 hours ago, Vincent Parrett said:I did experiment with that, but we ended up with build failures when multiple builds were running concurrently on different build agents.
Isn't that what Shared Resources are for?
-
23 hours ago, emileverh said:forward declaration of records, just like a class
Actually there is a way to achieve that using generics:
type TRecB<T> = record FieldA: T; FieldB: Integer; FieldC: string; end; type TRecA = record Secret: string; end; type TRecB = TRecB<TRecA>;
- 5
-
-
This is indeed very instable. One would need to extend the current internals significantly to make this work. Nevertheless one can achieve some results by setting AcceptExpressions to True and override these two methods:
type TNumberBox = class(Vcl.NumberBox.TNumberBox) protected function GetValidCharSet(AAcceptExpressions: Boolean): TSysCharSet; override; function IsNumericText(const AText: string): Boolean; overload; override; end; function TNumberBox.GetValidCharSet(AAcceptExpressions: Boolean): TSysCharSet; begin Result := inherited GetValidCharSet(AAcceptExpressions); if Mode = nbmFloat then Result := Result + ['e', 'E', '+', '-']; end; function TNumberBox.IsNumericText(const AText: string): Boolean; begin Result := inherited; if AText.LastIndexOfAny(['e', 'E']) = AText.Length - 1 then Result := False; end;
- 1
-
44 minutes ago, emileverh said:but why can they do it with classes and not with records....
You have already been told:
2 hours ago, Vandrovnik said:In forward declaration of a class, compiler immediatelly knows the size of that type. For records, their size would be unknown in forward declaration.
- 1
-
There is a reason why that is not supported:
type TRecA = record; TRecB = record FieldA: TRecA; end; TRecA = record FieldB: TRecB; end;
- 1
-
The current Delphi 12 version doesn't support that out of the box.
-
SetThreadDpiAwarenessContext has to be wrapped around the creation of a top level window handle to work correctly. All child windows then inherit the context of the top level one. This rules out any docked forms or frames, which explains why it is not feasible for the Embedded Designer. (Fun fact: an undocked designer window would have worked with that.)
A solution for this problem could be SetThreadDpiHostingBehavior and AFAIK that is something Embarcadero is investigating in.
-
As of today a rebuilt 11.3 web installer is available on my.embarcadero.com.
- 1
-
As of today there is a rebuild web installer for 11.3 available on my.embarcadero.com.
- 1
-
1 hour ago, PeterPanettone said:You don't believe in AI?
Sounds like it were a religion...
- 3
- 5
-
-
24 minutes ago, Brian Warner said:Is there a way to change the path to the GetIt server in 11.2?
Currently there is no GetIt server for 11.2! They are still working on it.
-
43 minutes ago, Connie McBride said:I'm actually not.
one of my .pas files is using CW_USEDEFAULT, which is leading to the compile error.
Then you seem to have Winapi.Windows.pas in your search path. Otherwise the compiler won't try to compile that issuing that error.
-
Question: Why are you compiling Winapi.Windows.pas in the first place?
- 2
-
14 hours ago, Ian Branch said:Does anybody know what the KSVC update changed/updated?
They probably just had to be recompiled.
-
1 hour ago, PeterPanettone said:Is there already any news about the new QP?
I am not aware of any.
-
I have issued a request to install the patch for All Users to fix these inconveniencies (it is a simple setting in the GetIt configuration). I hope someone will take care of that. Otherwise I have to wait for the new QP to get online.
- 2
-
GetIt creates a subkey in the registry under CatalogRepository for each installed item. It is probably there where the about dialog gets is information from, but I am only guessing.
Another weird thing is, that another user or registry branch (with -t parameter) won't see the patch either - albeit being installed.
-
6 hours ago, Nigel Thomas said:Bite the bullet. Download and install Delphi CE 11.3 (the current available CE edition). When you register for it, you'll get a new key. Migrate your project to the new version
I am with Nigel here: That seems to be the best solution.
What's the general opinion on v12?
in General Help
Posted
Interesting. That isn't visible in my browser: