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 2009

Official Google Webmaster Central Blog: How fast is your site?

Posted by jpluimers on 2009/12/05

Just so I remember if I ever need it:

Official Google Webmaster Central Blog: How fast is your site?.

–jeroen

Posted in Development, Web Development | Leave a Comment »

InterBase 2007: UPPER and collations (and a trick to specify the character set for string literals)

Posted by jpluimers on 2009/12/01

One of the applications that I’m currently involved with will in the future be used in different European countries.

Since it is developed in Delphi 2007, and uses InterBase 2007 we have chosen to use the ISO8859_15 character set: it is a single byte character set very similar to ISO8859_1, but supports the euro sign (€) and some other characters (Š, š, Ž, ž, Œ, œ and Ÿ).

When testing, we found out that UPPER would not always function as we expected.
Hence below some explanation about how UPPER behaves depending on the character sets and collation sequences you specify.

Note: most of this also holds for other versions of InterBase and for FireBird versions, but I have not checked everything with all versions yet, FireBird might be different as this piece of documentation shows.
If anyone does have the results for other InterBase or FireBird versions, please let me know the results.

Read the rest of this entry »

Posted in Database Development, Delphi, Development, Firebird, InterBase | Leave a Comment »

Generating EAN-13 barcode EPS files for your article numbers

Posted by jpluimers on 2009/11/30

Recently, I needed a bunch of EPS files for EAN-13 barcodes (that’s the kind of barcodes European companies put on their products).

Edit 20250520: added Wayback/Archive links but some of the below links died, so at the bottom I have added additional pages and properly archived them.

[Archive] Terry  Burton wrote a great barcode writer in pure PostScript for this, with a simple [Wayback/Archive] web front end to generate a barcode one at a time.

Read the rest of this entry »

Posted in Development, EPS/PostScript | 5 Comments »

GMail + TIFF = ? « Scientia potentia est

Posted by jpluimers on 2009/11/25

Ever wondered why since a couple of weeks you cannot preview TIFF attachments (like FAX images) in GMail any more?

It’s because GMail has (hopefully soon had!) a bug handling little-endian TIFF images: the preview of your attachment might reveal someone else’s!

While fixing it, GMail seems to have disabled the preview for all TIFF images.

Jaffar Rumith found about the bug more than a year ago, then rereported it, and blogged about it (GMail + TIFF = ? « Scientia potentia est).
Soon after his blog post got published, the bug got acknowledged (hopefully that is not cause and effect).

Viewing TIFF attachments didn’t work for a while either, but now works again.
Hopefully they will fix the preview TIFF issue soon…

–jeroen

Posted in GMail, Google | 1 Comment »

IIS Error 404 2 1260

Posted by jpluimers on 2009/11/09

This just had this happen on a Windows 2003 server with a client’s client.

Any .asmx page would return a 404 error like this IIS log line shows:

2009-11-06 09:46:05 127.0.0.1 GET /MyVirtualDirectory/MyWebService.asmx – 80 – 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729) 404 2 1260

Searching for “iis 404 2 1260 asp.net” found this top from Marc Valk, that solved the issue: ASP.NET v2.0.5727 was prohibited to run.
Which means that none of the ASP.NET bound extensions would work: they all returned 404 errors.

(Note: if you are wondering where your IIS log files are, this post shows you).

–jeroen

Posted in .NET, ASP.NET, Development, IIS, SOAP/WebServices, Software Development, Web Development | Leave a Comment »

XP embedded – .NET Framework 3.0

Posted by jpluimers on 2009/10/27

The “out of the box” .NET 3.0 component in Windows XP Embedded drags way too many required components (like the System Restore Core) into your image.

So most people build their own .NET 3.0 component.

If you get errors like this when you make your own, then you didn’t get your dependencies right.

These are the dependencies for the .NET 3.0 framework:

  • .NET Framework 2.0
  • ASP.NET 2.0

These are the error messages you get when you forget the ASP.NET 2.0 dependency:

Of course I always get all my dependencies right :-)
(yeah right, not this time)

–jeroen

Posted in Development, XP-embedded | Leave a Comment »

Delphi – for … in on enumerated data types

Posted by jpluimers on 2009/10/27

I like [Wayback/Archive] enumerated type a lot.
The allow you to perfectly describe what the members of such a type actually mean, much more readable than a bunch of integer constants!

Given an enumerated type like TTraphicLightColors

type
  TTraphicLightColors = (Red, Orange, Green);

I always wondered why  – since the for ... in statement was added to the [Wayback/Archivestructured statements part of the Delphi language – it is not possible to use a for … in statement like the this:

</span>
<pre>var
  TraphicLightColor: TTraphicLightColors;
begin
  try
    for TraphicLightColor in TraphicLightColor do
      ShowValueAsTraphicLightColor(Ord(Value));
    // [DCC Error] EnumerationEnumeratorDemoProcedures.dpr(63): E2430 for-in statement cannot operate on collection type 'TTraphicLightColors'
end;

Somehow, for ... in [Wayback/Archiveexpects a collection type.
A request for [WayBack/Archive] the for … in do on enumerated types compiler feature is in QC, but it is closed with reason “Won’t do”.

Back in Delphi 2007, I tried working around this by writing a type implementing the GetEnumerator pattern myself, but got [WayBack/Archive] Internal Errors when compiling anything but the most basic sample.

Until today, where I found how I could get that most basic sample to work!
It is an example on how you could implement this: it is research, so you decide if you find the result practical enough to use yourself.

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, F2084, QC, Software Development | 20 Comments »

Delphi operator overloading: table of operators, names, and some notes on usage and ‘glitches’

Posted by jpluimers on 2009/10/19

Operator overloading is a very nice feature of the Delphi language.
However. the Delphi documentation on Operator overloading is not completely right.

Below is my table of what I found out so far, and some notes.

It is part of my “Nullable types in Delphi” session that I gave on some conferences.
The downloads for that session contain more detailed information.

This is just an abstract to get you going and a try to answer this operator overloading question on Stackoverflow.
Download the full presentation to get more in depth information.

Let me know if you need more information.

Notes

Operator overloading

Add your own “behaviour” to operators

  • Win32: Works only for records, not classes!
  • An operator and the operand(s)
    are being implemented worden by a “class operator”;
    this is a kind of class method with name and argumen(s)

Example:

  • Multiplication X : = A * B;
  • Operator: *
  • Name: Multiply
  • Operands: 2 -> two parameters
type
  TMyRecord = record
    class operator Multiply(A, B: TMyRecord): TMyRecord;
  end;

Documentation is not correct!

Combining the rules of operator and result types, you can do magical things like Dances with XML | Australian Delphi User Group Members.

Do not use Delphi 2006 with operator overloading

Delphi 2007 fixed a number of bugs including this one: Delphi 2006 wont allow const parameters of type record within record method? – Stack Overflow.

10+ years later: maybe assignment operator?

It might be that in 2019, a new Delphi version gets assignment operator overloading: [WayBack] Operator Overloading Explained – Code Partners

Watch the result type of comparison operators!

Tips:

  • Some operators should be overloaded pair-wise
    = and <>
    shl and shr
    < and >=
    > and <=
    dec and inc
    + and –
    / and *
    div and mod
  • Prefer Explicit over Implicit operators
    • Beware of the built-in type coercion (implicit operators)
    • e.g
      • Byte to Integer;
      • Integer to Double;
      • Variants from/to anything!

Table of operators

operator # usage name cagetory *
and 2 R := A and B; BitwiseAnd bit
not 1 R := not A; //BitwiseNot bit glitch: does not exist!
or 2 R := A or B; BitwiseOr bit
xor 2 R := A xor B; BitwiseXor bit
() cast 1 R := TValue(A); Explicit conversion
:= 1 R := A; Implicit conversion
operator # usage name category *
round 1 R := Round(A); Round function
trunc 1 R := Trunc(A); Trunc function
and 2 R := A and B; LogicalAnd logical
not 1 R := not A; LogicalNot logical
or 2 R := A or B; LogicalOr logical
xor 2 R := A xor B; LogicalXor logical
operator # usage name category *
+ 2 R := A + B; Add binary
/ 2 R := A / B; Divide binary
div 2 R := A div B; IntDivide binary
mod 2 R := A mod B; Modulus binary
* 2 R := A * B; Multiply binary
2 R := A – B; Subtract binary
operator # usage name category *
shl 2 R := A shl B; LeftShift binary name is confusing
shr 2 R := A shr B; RightShift binary name is confusing
1 R := -A; Negative binary
+ 1 R := +A; Positive binary
dec 1 Dec(A); Dec self
inc 1 Inc(A); Inc self
operator # usage name category *
= 2 R := A = B; Equal comparison
> 2 R := A > B; GreaterThan comparison
>= 2 R := A >= B; GreaterThanOrEqual comparison
< 2 R := A < B; LessThan comparison
<= 2 R := A <= B; LessThanOrEqual comparison
<> 2 R := A <> B; NotEqual comparison
operator # usage name category *
in 2 R := A in B; In set

–jeroen

Posted in Conferences, Delphi, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Event, Software Development | 6 Comments »

Delphi – list of posts about hidden registry entries

Posted by jpluimers on 2009/10/15

There are quite a few registry tricks that you can perform to influence the Delphi IDE.

If you have any registry settings to share, please let me know by posting a comment below, or filling out the contact form.

This summary will be enhanced over time:

Have fun with them!

–jeroen

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

Delphi – finding the VERxxx define for a particular Delphi version: use JEDI.INC

Posted by jpluimers on 2009/10/15

Edit 20140822 since originally posting, JEDI moved to a GIT repository, so I changed some URLs and added that it is up to date until Delphi XE7.

Finding the correct VERxxx conditional define for a particular Delphi version is asked by a lot of people.

Even the first link in the above search, does not contain the full list!
But: JCL comes to the rescue

The JCL file JEDI.INC usually (read: like 99.999% of the time) is up to that with that information soon.
Currently, it contains all the defines starting with Delphi 1, up to Delphi 2010 XE7.

You can always browse the to JEDI.INC with this link to the sourceforge trunk. link to the GitHub master version.

In fact that file contains a lot more useful defines.
Actually, having the JCL and/or JVCL at hand is a very good practice: it is filled with high quality code that solves a lot of everyday problems.

Note:

VER190 (by some people attributed to the wrong Delphi version) is only used by Delphi 2007 for .NET (Delphi 2007 for Win32 used VER185 by itself and shares VER180 with Delphi 2006 for Win32).

The number 13 (in between Delphi 2009 aka Delphi 12, and Delphi 2010 aka Delphi 14) was never used as a Delphi version number
Since Delphi is mainly developed in the USA, and since a lot people there have Triskaidekaphobia, they showed mercy to those and skipped Delphi 13.

–jeroen

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Software Development | 9 Comments »