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,860 other subscribers

Archive for April, 2018

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 | 2 Comments »

TTemporaryFileStream – via DELPHI AREA » How to have a temporary stream, with no size limit

Posted by jpluimers on 2018/04/17

I needed a TTemporaryFileStream and found it at [WayBackDELPHI AREA » How to have a temporary stream, with no size limit.

It taught me that CreateFileA and CreateFileW (the ANSI and Unicode versions of [WayBackCreateFile function (Windows)) accept a FILE_FLAG_DELETE_ON_CLOSE parameter, so as soon as you close the handle, Windows will dispose of the file.

Note however that this will apply to the file handle so if you want to open it multiple times, you need [WayBackDuplicateHandle function (Windows) as per [Archive.isThe FILE_FLAG_DELETE_ON_CLOSE flag applies to the handle, also known as the file object, which is not the same as the file – The Old New Thing

–jeroen

Posted in Delphi, Development, Software Development, The Old New Thing, Windows Development | Leave a Comment »

Why you should try to avoid using Variant operations in Delphi

Posted by jpluimers on 2018/04/17

[WayBackDelphi “WAT?!” of the day: var v1, v2: Variant; begin v1 := True; v2 := True… shows some interesting code.

The [WayBackVariant Types (Delphi) – RAD Studio: Variant Type Conversions (and the decimal point/comma handling or rounding issues not documented there) usually kill you and are the most important reason to avoid Variant operations in Delphi.

–jeroen


// Delphi "WAT?!" of the day:
var
v1, v2: Variant;
begin
v1 := True;
v2 := True;
Writeln(v1 + v2); // -2
Readln;
end.

Posted in Delphi, Development, Software Development | 5 Comments »

The 68 things the CLR does before executing a single line of your code (*) · Performance is a Feature!

Posted by jpluimers on 2018/04/16

Because the CLR is a managed environment there are several components within the runtime that need to be initialised before any of your code can be executed. This post will take a look at the EE (Execution Engine) start-up routine and examine the initialisation process in detail.

Lots of interesting stuff happening before your code even gets executed. Many of the pieces can log.

Source: [WayBackThe 68 things the CLR does before executing a single line of your code (*) · Performance is a Feature!

Via: [WayBack] Good stuff to know! – Ondrej Kelle – Google+

–jeroen

Posted in .NET, C#, Development, Software Development | Leave a Comment »

Doing hardware upgrades, infrastructure rearrangements and software updates over this week. Expect some down-time…

Posted by jpluimers on 2018/04/16

This is upgrade/update week, so new disk space, and quite a bit of reorganisation going on.

Expect down-times in various portions of infrastatus.wiert.me

Secondaries should catch most, but some of the web-sites will be down for a while.

–jeroen

Posted in DevOps, Infrastructure, Power User | Leave a Comment »

Change Excel’s ‘edit in cell’ keyboard shortcut | Macworld

Posted by jpluimers on 2018/04/16

Learn one way to change Excel’s Control-U shortcut to the easier-to-use F2 (which also matches the Windows’ shortcut).

Ah, so Ctrl-U is the shortcut to edit a cell on Mac OS X with Microsoft Office Excel (:

Source: [WayBackChange Excel’s ‘edit in cell’ keyboard shortcut | Macworld

–jeroen

Posted in Apple, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, OS X 10.9 Mavericks, Power User | Leave a Comment »

BensonApproved – USB Type-C

Posted by jpluimers on 2018/04/13

Cables that really work well: [WayBack] BensonApproved – USB Type-C

Related to USB-C charging cables: not always as good as you’d think.

–jeroen

Via: [WayBack] [Q] Goeie USB-C kabel(s)? Ik ben op zoek naar een goeie usb-c kabels, liefst een beetje betaalbaar. Als ik bijvoorbeeld bij de Mediamarkt kijk (I know,… – Roderick Gadellaa – Google+

 

Posted in Development, Hardware Interfacing, Power User, USB, USB-C | Leave a Comment »

macos – When /tmp/wifi-*.log will show up and how can I stop it? – Super User

Posted by jpluimers on 2018/04/13

When you have many /tmp/wifi-{date}__{time}.log files, then this is how to get rid of them (it happened to me on a fresh Sierra machine):

At least on macOS Sierra (10.12):

  1. You can see what WIFI related components have debug logging enabled with:shell# /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport debug
  2. You can disable all debug logging with:shell# /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport debug -AllUserland -AllDriver -AllVendor

For whatever reason, the debug logging flag was enabled for ‘DriverWPA’ on my machine and that resulted in /tmp/wifi-{date}__{time}.log files getting generated when joining new WPA2 protected WIFI networks.

Source: [WayBackmacos – When /tmp/wifi-*.log will show up and how can I stop it? – Super User; thanks [WayBack] MattLord for answering that!

–jeroen

Posted in Apple, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Pro, macOS 10.12 Sierra, Power User | Leave a Comment »

Finding out why Github doesn’t render your reStructuredText as expected

Posted by jpluimers on 2018/04/13

One of the cool Github features is that it renders reStructuredText (and other markup documents like markdown).

Often however, your .rst file on GitHub looks very differently on GitHub as your local render. Heck: sometimes Github will not even render it at all.

 

–jeroen

Posted in Development, Lightweight markup language, MarkDown, Power User, reStructuredText, Software Development | Leave a Comment »