dzPrepBuild for Delphi 1.3.3 released

 Delphi, dzPrepBuild  Comments Off on dzPrepBuild for Delphi 1.3.3 released
Nov 022019
 

I just released version 1.3.3 of dzPrepBuild

The reason for this release was that I wanted to allow automatically updating the ProductVersion when the FileVersion changes. In order to do that, the tool now supports two additional placeholders that an be used in any version string: {MajorVer} and {MinorVer} which, as you might have guessed, resolve to the major and minor version number.

e.g.

[Version Info Keys]
CompanyName=www.dummzeuch.de
FileDescription=This is a Testproject for dzPrepBuild
FileVersion=1.0.0.2
InternalName={ProjectName}
LegalCopyright=Copyright 2002-{ThisYear} by Thomas Mueller
LegalTrademarks=
OriginalFilename={ProjectName}.exe
ProductName=Testproduct
ProductVersion={MajorVer}.{MinorVer}
BuildDateTime={today}

I also added {ProjectName} which resolves into the name of the Delphi project and is used in the example above for the InternalName and OriginalFilename entries.

While working on this enhancement unfortunately I also found a major bug that was introduced by a patch I accepted nearly years ago. It added support for private and special build flags but used the wrong names for these entries in the .dof, .bdsproj and .dproj files which resulted in –ReadDof, -ReadBdsProj and -ReadDproj failing. This is now also fixed. I never noticed this problem because I don’t use the built in Delphi version information any more. All my projects have an external [projectname]_version.ini file for maintaining the version information.

And since I was at it, I moved the project from SourceForge to OSDN. The new version can be downloaded from there.

 Posted by on 2019-11-02 at 14:55

PascalMagick – MagickDistortImage in Delphi

 Delphi  Comments Off on PascalMagick – MagickDistortImage in Delphi
Oct 222019
 

Playing around with ImageMagick I found that somebody already wrote a Pascal/Delphi import unit for it called PascalMagick. Unfortunately it has been integrated into freepascal which means Delphi support no longer has any priority.

So, the first thing to do was getting it to compile with Delphi.
It requires the ctypes unit from freepascal which did not compile because of an {$if …} that was terminated with an ${endif} rather than ${ifend} (line 107, newer versions fo Delphi won’t complain about this any more).

Then I opened one of the examples. There is a DPR file with an associated DPROJ file, but unfortunately that file was not a Delphi project file but some XML stuff. I renamed the LPR file (Lazarus Project) to DPR and it loaded into Delphi 2007.

Compiling worked too, but when I started it, I immediately got a System Exception with some cryptic error message. Half an hour later I knew the cause: The DLL could not be loaded, because there is an {$IFDEF Windows} around the MagickExport and WandExport constants (ImagageMagick.pas line 45). Delphi does not by default define this symbol. So I added it and the DLL still could not be found. WTF? Turned out that the DLL name was wrong. It’s now CORE_RL_MagickWand_.dll rather than CORE_RL_Wand_.dll. After that change the example program actually worked.

But I did not want to do the simple stuff but was interested in writing code that does what ‘magick -distort Perspective’ does. And I could not find anything in those units and include files that looked promising. Google finally turned up the MagickDistortImage function which is simply missing from import unit. So I added it:

type
  TMagickDistortImage = function(wand: PMagickWand; Method: DistortMethod; NumOfArgs: Integer;
        arguments: PDouble; bestfit: MagickBooleanType): MagickBooleanType; cdecl;

var
    MagickDistortImage: TMagickDistortImage;

  MagickDistortImage := GetProcAddress('MagickDistortImage');

But which values can be passed to the Method parameter? Again, it took me a while to find that enum declaration in C, so I converted it to Delphi:

type
  DistortMethod = (
    UndefinedDistortion,
    AffineDistortion, AffineProjectionDistortion, ScaleRotateTranslateDistortion,
    PerspectiveDistortion, PerspectiveProjectionDistortion,
    BilinearForwardDistortion,
    BilinearDistortion = BilinearForwardDistortion,
    BilinearReverseDistortion, PolynomialDistortion, ArcDistortion, PolarDistortion,
    DePolarDistortion, Cylinder2PlaneDistortion, Plane2CylinderDistortion, BarrelDistortion,
    BarrelInverseDistortion, ShepardsDistortion, ResizeDistortion, SentinelDistortion);

That’s how far I have come by now. I’ll put this here in case somebody else is as desparately looking for these declarations as I was for the last few hours.

 Posted by on 2019-10-22 at 16:00

efg’s Computer Lab and Reference Library is being restructured

 Delphi  Comments Off on efg’s Computer Lab and Reference Library is being restructured
Oct 212019
 

If you have done graphics processing in Delphi, you know efg’s computer lab which contained lots of great documentation and source code for that purpose. Unfortunately today on www.efg2.com you can read the following:

This site will be reorganized in the near future.

Prior to July 2019, this site contained 180+ pages on a variety of technical topics.
Links below are to copies on the Wayback Machine.

And since I am afraid that even those links will go away in the near future, I want to preserve them here:

Computer Lab on Wayback Machine (last snapshot from 2019-04-29)
The Computer Lab contains Lab Reports and Technical Notes on topics including, image processing, color science, computer graphics, mathematics, fractals & chaos, science & engineering. Most projects involve programming and include complete Delphi source code.

Reference Library on Wayback Machine (last snapshot from 2019-05-02)
The Reference Library contains two major sections, Delphi and Technical, each of which is a compendium of information from a wide variety of Internet resources.

The Delphi section is divided into a number of subsections and contains a large number of Delphi programming examples and code fragments. The Delphi Reference Library is mostly about technical topics (other than databases, except for the ADO subsection). The Algorithms, Graphics, Printing, and Math pages are the most popular.

The Technical section contains a large number of links to technical information. The Algorithms, Color, and Image Processing Reference Library pages are the most popular.

 Posted by on 2019-10-21 at 11:15

Several bugs regarding the GExperts Uses Clause Manager fixed

 Delphi, GExperts  Comments Off on Several bugs regarding the GExperts Uses Clause Manager fixed
Oct 192019
 

A few months ago I added the “Identifiers” tab to the GExperts Uses Clause Manager. It allows you to search for a unit that exports a given identifier. It works a bit like the “Find Unit” refactoring in the IDE since Delphi 2005.

That feature starts a background thread that parses all units in the search path to get a list of identifiers these units export. It works well with Delphi 2007 but recently I discovered that in Delphi 10.3.2 it finds “FreeAndNil” in various units which I am sure don’t export it:

So something must have been wrong with the parsing code.

It turned out that there were several bugs in that code, all related to language features added to Delphi later than Delphi 2007 (You may remember that I stated several times that I still do most of my work with Delphi 2007 so that version is the one with which GExperts has been tested extensively.).

These bugs have now been fixed and “FreeAndNil” only gets me the expected short list of units:

The changes have been committed to the svn repository (revisions #2807 and #2808), so if you want a DLL without this bug, you can compile your own.

 Posted by on 2019-10-19 at 20:20

All but one known GExperts code formatter bugs fixed

 Delphi, GExperts  Comments Off on All but one known GExperts code formatter bugs fixed
Oct 182019
 

Some long standing bugs in the GExperts code formatter have been fixed.

It’s great to see nearly all unit tests finally succeed.

About 10 new test cases have been added too, so the improvement is significant.

The fixed bugs including some that have bugged (sorry 😉 ) me for years, e.g.:

  Msg := Format('%s %s'#13#10
    + '%s',
    [a, b
      c]);

where the last line used to be indented the same as the previous line like this:

  Msg := Format('%s %s'#13#10
    + '%s',
    [a, b
    c]);

There is one left:

begin
  { testcomment
}s := '';
end;

where I am not even sure how it should be formatted. Maybe like this:

begin
   { testcomment
   }s := '';
end;

Or maybe it shouldn’t be changed at all.

Anyway, I’m thinking about making another GExperts release this weekend, but haven’t decided yet. If you want a fixed code formatter, you will have to compile your own DLL which isn’t rocket science after all.

 Posted by on 2019-10-18 at 13:55

Yahoo is closing down Groups

 Delphi, GExperts  Comments Off on Yahoo is closing down Groups
Oct 182019
 

I just read that Yahoo will be closing down Groups and will delete all content there.

By the end of October no new content will be accepted, by mid December all content will be deleted.

Why am I posting this? The GExperts mailing lists are hosted at Yahoo Groups, so they will be gone shortly. If you want to stay up to date or communicate with other GExperts users, there is either this blog (there is a GExperts RSS feedWhat is an RSS feed?), or the GExperts sub forum on the international Delphi Praxis forum.

Since Groups was the only remaining Yahoo feature I was using, have also just deleted my Yahoo account.

 Posted by on 2019-10-18 at 10:44

dzBdsLauncher 1.0.1 released

 Delphi, dzBdsLauncher  Comments Off on dzBdsLauncher 1.0.1 released
Oct 142019
 

dzBdsLauncher tries to solve the problem of accidentally opening a Delphi project with the wrong Delphi version. The latest version 1.0.1 now also reads the .DPROJ file to determine the Delphi version. See the dzBdsLauncher page for details.

 Posted by on 2019-10-14 at 17:20

Code Template examples saved from Code Central oblivion

 Delphi  Comments Off on Code Template examples saved from Code Central oblivion
Oct 102019
 

As I mentioned before, Embarcadero will turn off Code Central which will result in a wealth of Delphi code and tools vanishing from the face of the earth.

I have just saved two more entries for posterity:

  • Code Template Script examples [Archive.org]

    Code Template example for seeding a live template point with the clipboard contents. Also an example that modifies the ‘var’ code template allowing for initialization of the variable being declared.

    There are 2 templates included. A replacement for the var template and a new template called clippy that takes what is on the clipboard and surrounds it with a try…finally block.

    download link and

  • Code Template Basics – NewBucketList [archive.is]

    Code Template for Creating Code Template Basics – Delphi2006 by Adam Markowitz. NewBucketList code template is used as the example.

    download link

both by Adam Markowitz a former Borland Employee.

The Delphi Wiki has some more live templates.

 Posted by on 2019-10-10 at 16:39

TCsvWriter added to dzlib

 Delphi, dzLib  Comments Off on TCsvWriter added to dzlib
Oct 102019
 

Yes, I know, there are many already existing solutions for writing a CSV file in Delphi. And some are probably better than mine (for general purpose usage), but those I looked at had too many shortcomings for my particular use case, so I wrote my own. (There might also have been some not invented here syndrome involved.)

Anyway: It’s now in my dzlib as u_dzCsvWriter and there are also unit tests for it.

Note that I have tested it only with Delphi 2007 so far (because I needed it for Delphi 2007). There might be Unicode related bugs that only surface in later versions.

 Posted by on 2019-10-10 at 11:50

Digging in Archive.org: StringList value class

 Delphi  Comments Off on Digging in Archive.org: StringList value class
Oct 042019
 

I was just prompted to dig into archive.org to find an ancient (2008) blog post by Alan Bauer A “Nullable” Post which I used back then to implement the nullable types in dzlib.

A comment there mentioned this post on code central (archived). It’s about a StringList value class which frees you of the additional code necessary for creating and freeing a TStringList, so you can e.g. have a function that returns one without leaking memory. Interesting stuff by Janez Makovsek (who back then worked for Dew Research, no idea if he is still there)

StringList is the same as TStringList except that it is a value
type. It does not have to be created, destroyed or put within
try/finally. This is done by the compiler for you. There are
virtually no special performance penalties for these to work:

var
  strings: StringList;
  astr: string;
begin
  strings.Add('test1');
  strings.Add('test2');
  aStr := string(strings);
  RichEdit.Lines.AddStrings(strings);
end;

The code can be used as a template to wrap any TObject as a value class type.

Since Code Central is going to vanish from the face of the earth shortly, I have downloaded that ZIP file so it will be available for posterity.

 Posted by on 2019-10-04 at 16:47