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

Archive for 2009

Delphi – class helper to add for … in support for TComponent.Components / ComponentCount

Posted by jpluimers on 2009/05/07

You might have discovered that I’m a fan of Delphi class helpers.

This is another case where I’d like to use the for … in statement: accessing the Components of a TComponent instance.

So I wanted to end up with this:

procedure MyForm.FormCreate(Sender: TObject);
var
  Component: TComponent;
begin
  for Component in Self do
  begin
  // business logic goes here
  end;
end;

Read the rest of this entry »

Posted in Component Development, Delphi, Development | 12 Comments »

Delphi – class helper to get SourceFileName from an EAssertionFailed

Posted by jpluimers on 2009/05/06

In one of our applications, we have a default Config.xml file that is in our source tree, but it can be overridden by a Config.xml file relative to the application’s .EXE file.
So we have a two step process looking for the Config.xml, and we’d like to have the full path to the source file where the sources were build.
It seems the only way to get that, is by looking inside the Message of an EAssertionFailed exception.

So I wrote yet another class helper to get this code to work:
Read the rest of this entry »

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

Delphi – Michael Justin had strange floating point results when his 8087 FPU Control Word got hosed

Posted by jpluimers on 2009/05/06

Two days ago, [Wayback] Michael Justin (who just released version 1.7 of the [Wayback] Habari Active MQ Client components) posted a blog entry about a strange circumstance [Wayback] when 1.99 would not compare equally to 1.99.
He tracked it down to the [Wayback] 8087 (more formally: Intel [Wayback] FPU) Control Word being hosed on his system.

I could not reproduce his particular case, but since I have seen similar issues in the past, I wrote the DUnit test case below which shows you what can happen by manually setting the 8087 Control Word.

The difference between the 8087 Control Word values $1372 (default) and $1272 (failure) is the internal mantissa precision (see the [Wayback] “Art of Assembly Language” and the [Wayback] Intel FPU Control Word documentation on this).
Edit: Found a [Wayback] much more complete description of the bits in the FPU Control word.

It changes from 64 bits to 53 bits, which is enough to make 1.99 not equal to 1.99.

I have seen behaviour like this in the past with some networking stacks in the Turbo Pascal 7 era, with some C++ DLL’s in the Delphi 1-3 era, and some printer drivers in the Delphi 5-7 era.
Let me know in the comments (or using the contact form) where you have bumped into this.

The code below makes use of the Jcl8087 unit which is part of the JCL ([Wayback] JEDI Code Library) at [Wayback] SourceForge.
Add the unit to any DUnit test project you created and observe the results.
Read the rest of this entry »

Posted in 8087, Algorithms, Delphi, Development, Floating point handling, Software Development | 8 Comments »

Delphi / .NET interop – Atozed announced Crosstalk

Posted by jpluimers on 2009/05/06

On 20090504, Atozed announced Crosstalk: a technology that allows native Delphi code to consume .NET assemblies in a really intuitive and transparent way.atozed-logobig-white-bg

The announcement contains a FAQ.

It is a promising technology, not only because it is dead easy to use, but also because it is backed by Atozed: a team of people that have made complex technology like Web Apps easy to use by creating IntraWeb.

Expect demos soon (maybe even at Delphi Live!).
Here is a short example:

Read the rest of this entry »

Posted in .NET, Delphi, Development, Software Development | 3 Comments »

StUF – patch download for version 2.04 (patch.bg0204.2009.04.22.zip)

Posted by jpluimers on 2009/05/05

Late last month, EGEM i-team released a patch for StUF 2.04 (Dutch link) that you can download.

There are a few fixes in it, for us, the most important one was a fix we already patched ourselves: the fact that the element kadestraleGemeentecode was not of type KadestraleGemeentecode, but of the wrong type Gemeentecode.

More on that below, but first an error that is in the new patch: the bg0204.wsdl has one include too much. You have to remove this one in order to make it work correctly:

	<import namespace="http://www.egem.nl/StUF/StUF0204" location="..204\stuf0204.xsd"></import>

Note that due to a bug in the WordPress parsing engine (it usually kills backslashes that are followed by a zero), you might not see the correct path above:

It needs to start as follows:
dot
dot
backslash
zero
two
zero
four

You have to remove this because of two reasons:

  1. the imported bgstuf0204.xsd already includes the stuf0204.xsd (you do not want double includes!)
  2. for compatibility reasons WSDL documents should not contain backslashes

Read the rest of this entry »

Posted in Development, Software Development, StUF, XML/XSD | 6 Comments »

Dutch municipality ambivalence for stuff er… StUF

Posted by jpluimers on 2009/05/03

While on the one hand, Dutch municipalities are trying to ban stuff near schools by closing down coffeeshops that are withing a 250 meter of a school, they also love StUF.

This other StUF is the “Standaard UitwisselingsFormaat” or standard interchange format for IT-systems within municipalities.

It is an interesting set of standards that describe information interchange using either XML files defined by XSD or synchronous and asynchrous web-services defined by WSDL.

EGEM i-teams is the Dutch organization setting the StUF standards; their logo is on the right side. 
Maarten van den Broek is the guy behind the StUF standard.
The current version of the standard is 3.0 (Dutch link), but as it goes with standards, the actual version in use is 2.04 (Dutch link).

Since I have done quite some communication using the StUF 2.04 standard, I’d like to share some experiences with you in my blog.

Standards try to define a perfect world, where in fact the world is not perfect at all.
This holds for StUF 2.04 as well: in practice, the standard is not complete, has some pecularities (here and there even a bug) in it, and leaves things open for interpretation.
Also the parties implementing StUF do not always follow the rules, or sometimes extend the rules or add things that are not yet part of the standard.

This doesn’t make StUF a bad standard (actually, it is really good), and makes it really interesting.

So: enough stuff to talk about :-)

–jeroen

Posted in Development, StUF | Leave a Comment »

Jeroen turns 40 today :-)

Posted by jpluimers on 2009/04/29

Being born on April 29, 1969, Jeroen turns 40 today.

Posted in About | Leave a Comment »

WordPress – bug in sourcecode shortcode: backslash followed by zero is removed

Posted by jpluimers on 2009/04/28

See this support post:
http://en.forums.wordpress.com/topic/bug-within-sourcecode-backslash-followed-by-zero-is-removed

It seems even that post is affected by the same bug.

–jeroen

Posted in Development, WordPress | Tagged: | 2 Comments »

.NET/C# – an easier foreach for enums using generic methods

Posted by jpluimers on 2009/04/28

I like enums. Maybe because of my Turbo Pascal and Delphi background. They are descriptive. Makes code easier to read.

        public enum TrafficLightColors
        {
            Red,
            Yellow,
            Green
        }

But using them in C# foreach loops is a bit of a pain, not so much in the loop itself, but more in getting the list of values to loop over.
Read the rest of this entry »

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

Answered @ stackoverflow – on virtual constructors called through class references in Delphi

Posted by jpluimers on 2009/04/27

I just tried to elaborate on an answer to a question from Michael Justin on stackoverflow.
(yes, that’s the author of some message broker clients like the Habari ActiveMQ client that allows Delphi applications to talk to the Apache ActiveMQ message queueing broker).

His question is on virtual constructors and class reference: How can I detect if a Delphi class has a virtual constructor?
The combination of class references and virtual constructors is one of the fundaments of how Delphi became Delphi; in simple terms:

  • class references allow you to register components on the component palette in Delphi
  • virtual constructors allows the designer to construct  the instances of those components at design time

That’s why I think it is important to describe the distinction between virtual constructors and regular non-virtual constructors in the answer below (which is a copy of the answer I posted to stackoverflow)

Read the rest of this entry »

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