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

Delphi consensus: interface implementing classes expose methods at private or protected level.

Posted by jpluimers on 2020/09/02

Interesting consensus at which is very similar to my experience: [WayBack] I’ve inherited a project and the developer uses lots of interfaces (All good here!). Then when they develop the interfaced classes, the methods from th… – John Kouraklis – Google+

Some go even further and even declare the classes in implementation sections, but for me that gives too much RTTI hassle:

Private types (types in the implementation section of units) do not get qualified names.

via: Delphi: TRttiContext.GetType versus TRttiContext.GetTypes is not about singular versus plural…

–jeroen

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

What’s the piece of Delphi knowledge you find yourself looking up over and over again…

Posted by jpluimers on 2020/08/31

From an interesting thread at [WayBack] What’s the piece of Delphi knowledge you find yourself looking up over and over again? For me format strings is probably the thing that most stubbornly… – Lachlan Gemmell – Google+

On the generics side, I have wrote a few bits in my blog before, often pointing to information by others (many by Stefan Glienke as his skills on this topic are beyond excellent):

And on records:

There are some very good books on Delphi though that dig deeper than the documentation:

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 4 Comments »

“Fatal: F1027 Unit not found: ‘System.pas’ or binary equivalents (.dcu)”

Posted by jpluimers on 2020/08/25

If you ever get a “Fatal: F1027 Unit not found: ‘System.pas’ or binary equivalents (.dcu)” – Google Search, then it is likely because you:

  1. build from a script
  2. build use a user that has never ran the Delphi IDE

This is common for unattended builds (like build-automation).

For each run, the Delphi IDE will save an EnvOptions.dproj with global settings.

Since build scripts should not rely on global settings, you need to ensure those are in your project settings.

Some background reading on this:

–jeroen

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

Spring4D – Shared, Weak references

Posted by jpluimers on 2020/08/25

In addition to Shared/IShared, there is also Weak/IWeakReference in Spring.pas; these blog post explain more about them:

Related: If you were using Managed / IManaged in Spring4D, be aware they got renamed to Shared / IShared.

–jeroen

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

Delphi unit aliases: multiple ones can point to the same unit

Posted by jpluimers on 2020/08/20

A while ago, I had to figure out how to get some GExperts stuff cross-compile to older Delphi versions, because of UITypes usage that is not available in Delphi XE and lower (but much of what it contains is in the Types unit).

So I went down memory lane, as I remember in Delphi 2, the Delphi 1 WinTypes and WinProcs units were merged into the Windows unit.

A quick search revealed the stackoverflow entry mentioned here:

for the Delphi 1 -> Delphi 2 migrations, these aliases were used where multiple units pointed to the same one:

WinTypes=Windows;WinProcs=Windows;DbiProcs=BDE;DbiTypes=BDE;DbiErrs=BDE

See [WayBack] delphi – wintypes.dcu not found and code completion stops working – Stack Overflow

A longer search found this in my own archives:

File D2-CS-2.0\DEMOS\DOC\AUTOPROJ\AUTOPROJ.DOF

Has this line:

UnitAliases=WinTypes=Windows;WinProcs=Windows

Source: [WayBack] GX_GenericUtils.pas fails to build in Delphi 2007 because it uses unit UITypes · Issue #22 · jpluimers/GExperts · GitHub

(Ab)using unit aliases to fail on VCL

You can use unit aliases so your applications cannot use the VCL any more.

The trick is to alias Forms or VCL.Forms into something that does not exists, like Forms=__no_VCL_Forms__. The reason this works is that any VCL application uses the Forms unit because of the Forms.Application variable.

Reference:

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, GExperts, Software Development | Leave a Comment »

Don’t use the TPL as it still has rough edges in unsuspected places

Posted by jpluimers on 2020/08/20

A few posts on why not to use the TPL and be very careful with regular RTL threading code:

In my opinion, threading code needs to be written and maintained by people that live and breath multi-threading. Over the years, RTL and TPL have not lived up to that, but a library like [WayBack] OmniThreadLibrary has.

If you still insist on the TPL, or want to break it, start with these posts: [WayBack] Parallel Programming Archives • Stephen Ball’s Technical Blog

–jeroen

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

TMonitor versus Critical sections revisited: when possible, use SRWL over TMonitor, then TCritical section

Posted by jpluimers on 2020/08/19

Via [WayBack] TMonitor vrs Critical sections revisited. Back then (https://www.delphitools.info/2013/06/06/tmonitor-vs-trtlcriticalsection/), it was found that critic… – Kiriakos Vlahos – Google+ as he re-did the measurements that DelphiTools did before Delphi XE5 came out:

Slim Reader/Writer Lock (SWRL) is even faster than TMonitor:

  • CriticalSection 0.035
  • TMonitor 0.019
  • SWRL 0.012

Of course if you have a speedy lock-free solution, that is always favourable, but few people know how to write lock free data structures or how to find the libraries (despite Julian Bucknall covering quite a few of them in Delphi back in the days).

Related:

–jeroen

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

In the series “avoid Variants when coding in Delphi”: the comparison operator

Posted by jpluimers on 2020/08/18

For Variant types, the = comparison operator in Delphi maps to the VarCompareValue in the Variants unit.

That function fails to handle various comparisons and for some it knows it can handle raises a VarInvalidOp through various code paths (like CheckType) to VarInvalidOp because the implementation limits itself to varEmpty..varUInt64, which I think means that these are unsupported:

  • varRecord
  • varStrArg
  • varObject
  • varUStrArg
  • varString
  • varAny
  • varUString
  • varArray
  • varByRef

This fails when using the = operator:

What is this code supposed to do, if v1 and v2 are variant arrays with the same content?

if v1 = v2 then
  WriteLn('equal')
else
  WriteLn('not equal');

Spring4d has a function SameValue in the Spring.pas unit which handles more cases, at least the case when both operands are arrays having the same content.

Source: [WayBack] I think I may have mentioned that I hate Variants: What is this code supposed to do, if v1 and v2 are variant arrays with the same content? if v1 = v2… – Thomas Mueller (dummzeuch) – Google+

Thanks to Thomas Mueller and Stefan Glienke for this.

–jeroen

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

Remote access to the Embarcadero License Center via SSH tunnel – twm’s blog

Posted by jpluimers on 2020/08/10

Thomas basically did all the research on the forwarding needed for ELC (formerly Belise/Elise), then showed the PuTTY equivalent to ssh user@remote -L5567:192.168.1.200:5567:

[WayBackRemote access to the Embarcadero License Center via SSH tunnel – twm’s blog

Via: [WayBack] Once you have set up an Embarcadero License Center (ELC) for your company (with network named user or concurrent licenses) you will need network access … – Thomas Mueller (dummzeuch) – Google+

Related: [WayBack] Introducing the Embarcadero License Center – ELC

–jeroen

 

Posted in *nix, Communications Development, Delphi, Development, Internet protocol suite, Licensing, Power User, Software Development, SSH, ssh/sshd | Leave a Comment »

Delphi: Download multiple files in multiple parts at the same time, support resuming, gzip-encoded files, cookies, logging to websites using POST and so on

Posted by jpluimers on 2020/08/05

If I ever need to download multiple files in multiple parts at the same time, support resuming, gzip-encoded files, cookies, logging to websites using POST and so on, then I need to look at [WayBack] http – Delphi- downloading files from the web with sockets – Stack Overflow.

–jeroen

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