The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,854 other subscribers

Archive for the ‘Delphi’ Category

Before using the PPL, I need to check to see if a few things have been fixed yet

Posted by jpluimers on 2019/10/31

Before using the PPL ever, I need to check out at least a few posts like these:

Most of the PPL code was written by Allen Bauer when he was Chief Scientist at Embarcadero in the 2007-2010 time frame and it was still called DPL (Delphi Parallel Library). The code was released in Delphi XE7 (see [Archive.isUsing the Parallel Programming Library – RAD Studio) but seems hardly maintained after he left.

You can find some of his notes at [Archive.isThe Oracle at Delphi: Parallel Programming

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

E2398 Class methods in record types must be static (Delphi) – RAD Studio

Posted by jpluimers on 2019/10/29

[WayBack] E2398 Class methods in record types must be static (Delphi) – RAD Studio present since at least Delphi 2007 ([WayBack] E2398: Class methods in record types must be static).

This is a Delphi compiler limitation for records, that is not present for classes.

Maybe one day when record inheritance kicks in, this will be resolved (as Stefan Glienke hinted in the below tread), because currently Self (which is present in non-static class methods on classes) then points to the current type. In static class methods, there is no Self, which is OK as that would point to the only available type anyway.

Via: [WayBack] why a class method of a record without the static keyword raise E2998 error ? AFAIK it can not be anything else then static ?! – Paul TOTH – Google+

Note that [WayBack] Error and Warning Messages (Delphi) – RAD Studio shows various other errors around the use of static:

All are marked “No further information is available for this error or warning.“, though they would at least deserve some examples.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Spring4d Marshmallow ORM – ensuring the right identifier quoting is used

Posted by jpluimers on 2019/10/29

When an ORM generates the SQL for a certain database back-end, it needs to use the right quoting.

Normally, the Spring4D Marshmallow project derives that from the back-end specific adapter used.

But if you use a generic TDriverConnectionAdapter, then you need to manually set the QueryLanguage property in your IDBConnection using a valid value from Spring.Persistence.SQL.Interfaces. This then uses the correct SQLGenerator from the TSQLGeneratorRegister to generate the SQL including correct quotes.

To quote identifiers, most back-ends use a double quote, but MySQL uses a backtick.

via:

You obviously already modified that code as the commented out code is the correct one.
I guess you already got that mistake when you started using MySQL via ADO as MySQL needs the backtick.

Set QueryLanguage of your IDBConnection properly (the valid values are in Spring.Persistence.SQL.Interfaces). Then the correct SQLGenerator will be used.
If you are using an adapter that is specific to a certain database then it sets the QueryLanguage properly but if you are using an adapter for components that can connect to multiple databases (like ADO or FireDAC) it does not, hence the need you specify it.

 

–jeroen

Posted in Delphi, Development, Software Development, Spring4D | Leave a Comment »

Delphi code completion fail with anonymous methods – Stack Overflow

Posted by jpluimers on 2019/10/28

[WayBack] Delphi code completion fail with anonymous methods – Stack Overflow.

It also often fails by inserting end; inside if/then/else statements having a proper begin/end blocks.

The reason is that code completion uses a different parser than the regular Delphi compiler.

Chances of these issues to get fixed are close to zero, because another part of the problem is that there is no formalised Delphi language grammar, not even at Embarcadero itself.

I wish there was an Embarcadero sanctioned grammar (see [WayBack] “The arguments that won the day for us here were about strengthening the ecosystem and becoming the best tooled language on the planet. They were about … – Jeroen Wiert Pluimers – Google+). Actually I had that wish like in the end of the 1990s, but I cannot find my forum post archive back.

The best reverse engineered grammar is DelphiAST: a well maintained open source project implementing an Abstract Syntax Tree for Delphi.

Via: [WayBack] SO…/delphi-code-completion-fail-with-anonymous-methods I have seen this question and I am curious. There is an… – Alberto Miola – Google+

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

use the JVCL’s TJvXxxAppStorage to store float values as strings while controlling the decimal separator…

Posted by jpluimers on 2019/10/24

For my link archive: [WayBack] Is there a way to use the JVCL’s TJvXxxAppStorage to store float values as strings (e.g. “10.152”) rather than hex dumps and also control the decimal separator… – Thomas Mueller (dummzeuch) – Google+ with a solution by Achim Kalwa:

+Thomas Mueller You may try this:

type
  TMyStorage = class(TJvAppRegistryStorage)
  protected
    procedure DoWriteFloat(const Path: string; Value: Extended); override;
  end;
  TJvAppRegistryStorage = class(TMyStorage);
...
Implementation

{ TMyStorage }

procedure TMyStorage.DoWriteFloat(const Path: String; Value: Extended);
var
  SValue : string;
  FS     : TFormatSettings;
begin
  FS := TFormatSettings.Create;
  FS.DecimalSeparator := '.';
  FS.ThousandSeparator := #0;
  SValue := FloatToStr(Value, FS);
  DoWriteString(Path, SValue);
end;

And you need to set
StorageOptions.FloatAsString := False;

–jeroen

 

Posted in Delphi, Development, Software Development | Leave a Comment »

When the Delphi IDE gets slow…

Posted by jpluimers on 2019/10/24

A few tips for when the Delphi IDE gets slow, try these step by step:

  1. Install Delphi Fix-Pack by Andreas Hausladen (a.k.a. Andy)
  2. Disable “Error Insight”
  3. Disable or install LiveBindings related packages

The first can be hard to find as his site disallows search engine indexing, but I’ve written about it before site:wiert.me delphi fixpack andy.

The second step is not a package, but an IDE setting:

The last step involves packages like these (package path followed by package description in the order of the registry):

$(BDSBIN)\dclBindCompFireDAC220.bpl            LiveBinding Expression Components FireDac
$(BDSBIN)\dclbindcomp220.bpl                   Embarcadero LiveBindings Components
$(BDSBIN)\dclbindcompvcl220.bpl                Embarcadero LiveBindings Components VCL
$(BDSBIN)\dclbindcompdbx220.bpl                LiveBindings Expression Components DbExpress
$(BDSBIN)\dclbindcompfmx220.bpl                Embarcadero LiveBindings Components FireMonkey

In those, $(BDSBIN) and $(BDS)\Bin point to the same directory.

Parts via: [WayBack] EDIT: Pretty sure Fix-Pack solved the speed issue, as I installed it and things started flying. I was trying to be as stock as possible, in order to und… – Vin Colgin – Google+

–jeroen

 

Posted in Delphi, Development, Software Development | 1 Comment »

Spring4D and factory – for my link archive

Posted by jpluimers on 2019/10/23

So I remember as resolving container things can be tricky:

–jeroen

Posted in Delphi, Development, Software Development, Spring4D | Leave a Comment »

Reminder to self: check progress on Delphi helper requests

Posted by jpluimers on 2019/10/23

One of the things the Delphi language really could use some updates in is helpers.

A semi-random example is in [WayBack… It nags me that I can’t create a record helper for a generic type… – Lars Fosdal – Google+.

So I wonder if there has been any progress, and this is a post to remind me checking it out.

Example feature requests (no more QC, so these have to do) by Horácio Filho:

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

DelphiSpringTrees – Trees in Spring4D

Posted by jpluimers on 2019/10/22

From a while back: [WayBack] I just commited a version of (my suggestion for) DelphiSpringTrees; this is the first version that I’m happy with. Features: – Fast – Does not use or … – Johan Bontes – Google+

The repository for “DelphiSpringTrees – Trees in Spring4D” is at https://github.com/jpluimers/DelphiSpringTrees

–jeroen

Posted in Delphi, Development, Software Development | 1 Comment »

The Delphi System.Exit “Function”

Posted by jpluimers on 2019/10/17

Still wrongly documented as System.Exit Function [WayBack], most people think it is a statement.

However, it is a compiler intrinsic procedure in the System unit that – when called inside a real function – optionally accepts a parameter with the same type as the encompassing function because it is a compiler intrinsic. It kind of acts as an overloaded procedure, but in fact translate to machine code via an intermediate parse tree.

The parameterless version has been there since at least Turbo Pascal 3.0, but the parameterised version is more recent: I think it was introduced around Delphi 7.

It then stops executing that function after first executing any explicit or implicit finally blocks.

I’ve seen various projects that used their own Exit procedure. This is a very bad habit: Since the System unit is always further away in scope, the introduced one is called which can severely confuse programmers not being aware of this.

The code generation for the parameterless and parameterised  “overloads” of System.Exit is slightly different:

  • The parameterless one can often be optimised away, for instance folding multiple calls to them into one, or rearranging code execution so a jump isn’t needed any more. This means you cannot always put a breakpoint on them.
  • The parameterised one always needs code to load the function result, so you can always put a breakpoint on them.

Stefan Glienke explained the above in [WayBack] The advantage of using Exit() instead of a plain Exit? You can place a breakpoint! – Uwe Raabe – Google+

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 1 Comment »