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,368 other followers

Archive for the ‘Delphi XE3’ Category

Tip for the doc team: make TMonitor.Enter docs more clear on non-blocking re-entry from the same thread

Posted by jpluimers on 2018/04/19

Even when the Delphi team was large, the documentation was lacking, so with the reduced Delphi team size, I don’t have high expectations of the below to get fixed.

But since much of the post Delphi 7 run-time library looks a lot like the .NET core, you can usually fallback to the Microsoft documentation.

Tip for the doc team: make http://docwiki.embarcadero.com/Libraries/en/System.TMonitor.Enter more clear. Especially that if the same thread calls TMonitor.Enter more than one time, it will allow entry without blocking as per System.Threading.Monitor.Enter Method (Object) documentation https://msdn.microsoft.com/en-us/library/de0542zz

(note that this got introduced in Delphi XE3: http://docwiki.embarcadero.com/Libraries/XE3/en/System.TMonitor.Enter)

–jeroen

via: [WayBack] Tip for the doc team: make http://docwiki.embarcadero.com/Libraries/Seattle/e…

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

Reminder to Self: `TProc` is incompatible with parameterless procedures on interfaces

Posted by jpluimers on 2018/04/19

I knew that methods on interfaces were not compatible with the procedure of object (like [WayBack] TProc)or function of object construct, but they are also not compatible with the reference to procedure or reference to function construct.

Via: [WayBack] I try to call an Interface method from TThread.Syncrhonize()…and Berlin don’t accept that… – Paul TOTH – Google+

If you want it fixed, vote for [RSP-13007] Interface methods are not assignable to anonymous method variable – Embarcadero Technologies (Thanks Stefan Glienke).

You can work around it with an anonymous method.

This won’t work:

program Project1;
{$APPTYPE CONSOLE}
uses
  SysUtils;
 
type
  ITest = interface
    ['{B5AD87E8-A3DF-4B83-BE14-997C2E76A06C}']
    procedure Run;
  end;
 
  TTest = class(TInterfacedObject, ITest)
    procedure Run;
  end;
 
procedure TTest.Run;
begin
  Writeln('PASS')
end;
 
var
  test: ITest; // <- change this to TTest and it compiles
  proc: TProc;
begin
  test := TTest.Create;
  proc := procedure begin test.Run; end; // <- this compiles
  proc := test.Run; // E2010 Incompatible types: 'TProc' and 'procedure, untyped pointer or untyped parameter'
  proc();
  Readln;
end.

–jeroen

 

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

… / source / Native / Delphi / Library / Data / DataSetEnumeratorUnit.pas — Bitbucket

Posted by jpluimers on 2018/04/18

Reminder to self that I one day need to write more about this enumerator:

[WayBackjeroenp / BeSharp.net / source / Native / Delphi / Library / Data / DataSetEnumeratorUnit.pas — Bitbucket

It’s not nearly as good as the one by Uwe Raabe, but I didn’t really update this code for about a decade as it has functioned well for me in the current state: in 2009 it was like [WayBackbo library – Source Code.

Code by Uwe is at [WayBackDataset Enumerator Reloaded | The Art of Delphi Programming via [WayBack] Refurbishing old code: http://www.uweraabe.de/Blog/2017/02/09/dataset-enumerator-reloaded/Uwe Raabe – Google+

A couple of years ago I wrote a two-part article about a dataset enumerator: A Magical Gathering – Part 1 and Part 2. Well, things evolved a bit since then and I wondered how one would implement something similar given the current features of Delphi. Actually I am following here a suggestion from commenter Alan Clark.

So for now it’s just to document that my enumerator is there and that it works as intended.

I referenced an older version at [WayBackFor-in Enumeration – ADUG as I used it at Spoken @ CodeRage III, December 1-5, 2008 on Delphi, database and XML related topics and Source: Conferences/2009/DelphiLive.2009/Smarter-code-with-databases-and-data-aware-controls.

A small video on how you use it is here:

It was back when Better Office and CodeGear still existed and we celebrated (late) Gwan Tan’s 50th birthday.

O the days (:

More history:

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 1 Comment »

Delphi attributes cannot use `const x: array of string` as argument

Posted by jpluimers on 2018/04/12

[WayBack] I want to annotate some of my enumerated types with human facing names. So I want to write: type[Names(‘Explicit time domain’, ‘Implicit time domain’,… – David Heffernan – Google+

This does not work:

constructor Create(const Values: array of string);

It seems to be in QC.

The reason is not obvious until you realise (thanks Stefan for wording that) that attribute constructor arguments are limited to anything that can be const. Open arrays nor dynamic arrays can be const (yes, nowadays you can have “consts” that are dynamic arrays but in fact they are compiler protected variables).

An alternative you might think works, but fails us using one attribute per enumeration element. But that’s where Delphi RTTI leaves you in the dark: it does not expose the RTTI for enumeration elements (likely doesn’t even generate it), only the the enumeration type itself.

So this fails:

type
  NameAttribute = class( TCustomAttribute )
  private
    FName: String;
  public
    constructor Create( AName : String );
    property Name: String read FName;
  end;

  TMyEnumeration = (
    [Name('One')]
    meOne,
    [Name('Two')]
    meTwo
  );

–jeroen

 

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

Do not use non-ASCII characters as identifiers – not all your tools support them well enough

Posted by jpluimers on 2018/04/05

For a very long time I’ve discouraged people from using non-ASCII characters in identifiers. It still holds.

In the past, transliterations messed things up. Even with increased support for Unicode, tools still screw non-ASCII characters up.

Delphi is not alone in this (the most important one is the DFM view as text support), see this report: [RSP-16767] Viewing a form as text fails with non ascii control or event names – Embarcadero Technologies (you need an account for this, but the report is visible for anyone):

Viewing a form as text fails with non ascii control or event names Comment

Steps:

  1. create a new VCL forms application
  2. drop a label onto the form
  3. change the name of that label to lblÜberfall (note the U-umlaut)
  4. switch to view as text
  • exp: DFM content shown as text
  • act: first line is shown incorrectly (see screenhsot)

–jeroen

Source: [RSP-16767] Viewing a form as text fails with non ascii control or event names – Embarcadero Technologies

via: [WayBack] Code of the day – – Thomas Mueller (dummzeuch) – Google+:

function TNameGenerator.StrasseToStrasse(const _Strasse: string): string;
begin
Result := _Strasse;
end;

Strasse := StrasseToStrasse(_Strasse);

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

 
%d bloggers like this: