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 the ‘Delphi 2009’ Category

Rudy’s Delphi Corner – Pitfalls of converting, on converting from C/C++ to Delphi

Posted by jpluimers on 2015/09/02

If ever in need to translate C/C++ headers or code to Delphi, this refernece by Rudy Velthuis – a dentist with a strong interest in programming – is the best I could find: Rudy’s Delphi Corner – Pitfalls of converting.

It is written in a pretty version agnostic way, and covers the vast majority of conversion topics.

And it has been updated over time numerous times.

–jeroen

Posted in Borland C++, C, C++, C++ Builder, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 10 Comments »

GoF Patterns in Delphi | Implementations of the famous Gang of Four Design Patterns in Delphi language – via Nick Hodges

Posted by jpluimers on 2015/08/20

Thanks to Nick Hodges for having Delphi-losophy | Flotsam and Jetsam #88 point me to GoF Patterns in Delphi | Implementations of the famous Gang of Four Design Patterns in Delphi language.

–jeroen

Posted in Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Software Development | 2 Comments »

Fuzzing in addition to Unit Tests – via: David Millington G+

Posted by jpluimers on 2015/08/11

I need to give this link from Jonathan Lange which was shared by David Millington some thought:

Embedded in Academia : How to Fuzz an ADT Implementation.

There they add fuzzers to help testing an ADT: in this case an Abstract Data Type in the form of  a red-black tree.

And then see if it can be added to DUnit and NUnit or MSTest/VSTest in some way.

In the original post by Jonathan Lange, an important remark was made by Eric Castelijn:

… the downside being that having non deterministic tests means having test failures that are hard to repeat

When fuzzing multiple or composite values, the chances that you will hit interesting edge cases semi-reliably will drop dramatically, in my experience

–jeroen

via “This post has two points. First, you should write ADT fuzzers. It is often….

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Delphi, 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 »

Delphi: turn off column or line block selection mode – via: Default IDE Shortcut Keys; Delphi Programming

Posted by jpluimers on 2015/07/30

The Default IDE Shortcut Keys – Delphi Programming was a good starting point to find out how to disable column or line blocks.

Since the table there is incomplete (even the Embarcadero documentation is wrong as some shortcuts can turn on and off a mode), here are the relevant shortcuts keys:

Ctrl + O + C Turns on/off blockcolumn selection mode Delphi 5 and up
Ctrl + O + K Turns on/off block selection mode Delphi 5 and up
Ctrl + O + L Selects current line (and turns off block selection mode) Delphi 5 and up

This is especially useful when the block selection is stuck (this happens every now and then: it’s a known bug).

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 6 Comments »

20 resources on migrating to Unicode with Delphi | Software on a String

Posted by jpluimers on 2015/07/08

Great post by Marjan Venema when you need to migrate your old Delphi programs to the modern Delphi world: [Wayback] 20 resources on migrating to Unicode with Delphi | Software on a String.

I’m glad that some of the links overlap with what I posted and presented in the past at:

Well done Marjan!

–jeroen

Posted in Ansi, ASCII, Delphi, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Encoding, Software Development, Unicode | Leave a Comment »

On the Delphi TCommandParser class for parsing command-lines and arguments (via: Suggestions for how to define command line parameters – Stack Overflow)

Posted by jpluimers on 2015/05/13

A while ago, I posted [WayBack] the below StackOverflow answer. Recently a friend asked me about command-line parsing in Delphi, so here is the re-run:

Delphi contains a really nice unit called CommandParser with a [WayBack] TCommandParser class that does commandline parsing for you. Since it has [WayBack] virtually no documentation, here are a few things to get started. It works even in Delphi 2007.

I have a HiddenExecutable example at our open source bo repository.

Basically you:

  • TComponent that contains the properties you want to expose as commandline parameters (that is THiddenExecuteSettings in the HiddenExecuteSettingsUnit
  • a commandline parser controller. In our case THiddenExecuteArguments in theTHiddenExecuteArgumentsUnit (in retrospect not such a good name) that contains an InitCommandLine method that sets up a TCommandParser instance passing it your TComponent
  • It then executes a couple of [WayBack] AddSwitch calls to setup the parameters with both abbreviated and full commandline switches (like h and help)
  • ProcessCommandLine method on the TCommandParser instance to process the commandline and fill the properties of your TComponent (in my example, this is done in the ProcessCommandLine method).

Now comes the fun:

  • TCommandParser has a HelpText method that fully automatically assembles a helptext based upon what you fed it with the AddSwitch methods.
  • TCommandParser also has a SaveOptions method that allows you to save the current settings of your TComponent into a settings file.

The Delphi units you need are these which you can get from the Embarcadero [WayBack] radstudiodemos.sourceforge.net demo repository:

CommandParser in '...\radstudiodemos.sourceforge.net\branches\RadStudio_XE2\Delphi\Database\dbExpress\Utils\CommandParser.pas',
PropertyHelpers in '...\radstudiodemos.sourceforge.net\branches\RadStudio_XE2\Delphi\Database\dbExpress\DbxDataPump\PropertyHelpers.pas',
ParseIds in '...\radstudiodemos.sourceforge.net\branches\RadStudio_XE2\Delphi\Database\dbExpress\DbxDataPump\ParseIds.pas',

Edit: [WayBack] John Kaster wrote a nice [WayBack] article on EDN that includes [WayBack] more details on using the TCommandParser.

Note the above mentioned code mostly is on [WayBack] https://bitbucket.org/jeroenp/wiert.me/src/tip/Native/Delphi/Apps/Console/HiddenExecuteConsoleProject

Since Delphi XE7, this unit does not ship with Delphi any more, but it is still at [WayBack] RAD Studio Demo Code / Code / [r2029] /branches/RadStudio_XE6/Object Pascal/Database/dbExpress/Utils/CommandParser.pas.

–jeroen

via: [WayBack] delphi – Suggestions for how to define command line parameters – Stack Overflow.

Posted in Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Software Development | 4 Comments »

Delphi Component vendors: when you ship source code, make it IDE-browsable as well by compiling with $YD or $Y+

Posted by jpluimers on 2015/05/06

It took me a while to figure this one out:

When you have a registered Delphi, you can Ctrl-Click browse both the units and symbols of RTL, VCL, etc. But Delphi will not recompile these units.

Some third party components you cannot Ctrl-Click browse the units or symbols, unless you put the source directory in the Delphi Library Path (which causes them to be compiled each and every time).

This is because:

  • the precompiled DCUs are in the Delphi Library Path.
  • the source code is added to the Delphi Browsing Path (and sometimes not even that).
  • the DCUs don’t contain information that the source code is Browsable or Referencable as it was compiled with {$Y-}.

These are the possible values for that directive:

  1. {$Y-} or {$DEFINITIONINFO OFF} or {$REFERENCEINFO OFF},
  2. {$Y+} or{$REFERENCEINFO ON},
  3. {$YD} or {DEFINITIONINFO ON}

So please component vendors: when you ship source code, make it IDE-browsable as well by compiling with $YD or $Y+.

–jeroen

via:

Posted in Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Development, Software Development | 2 Comments »

Delphi on Windows x64: solution when project compiles fine under IDE, but not using MSBuild

Posted by jpluimers on 2015/04/21

Especially when using Delphi 2007 on Windows x64 system (8.x, 7, Vista, 2012 Server, 2008 Server, …), the Delphi specific .Targets files used by msbuild are simply installed to the wrong location.

A better warning for this is in my BeSharp.net repository: Run-Dependend-rsvars-From-Path.bat thanks to David Millington who wrote this:

If you copy

  • Borland.Common.Targets
  • Borland.Cpp.Targets
  • Borland.Delphi.Targets
  • Borland.Group.Targets

from

  • %windir%\Microsoft.NET\Framework\v2.0.50727

to

  • %windir%\Microsoft.NET\Framework64\v2.0.50727

then building via the command line works.

The rsvars.bat file is correct.

Note that my batch file checks for all target file sets:

Delphi 2007:

  set requiredTargets=Borland.Common.Targets Borland.Cpp.Targets Borland.Delphi.Targets Borland.Group.Targets

Delphi 2009 and up:

  set requiredTargets=CodeGear.Common.Targets CodeGear.Cpp.Targets CodeGear.Delphi.Targets CodeGear.Deployment.Targets CodeGear.Group.Targets CodeGear.Idl.Targets CodeGear.Profiles.Targets
  if %bdsVersion%==8 set requiredTargets=CodeGear.Common.Targets CodeGear.Cpp.Targets CodeGear.Delphi.Targets CodeGear.Group.Targets CodeGear.Idl.Targets
  if %bdsVersion%==13 set requiredTargets=CodeGear.Common.Targets CodeGear.Cpp.Targets CodeGear.Delphi.Targets CodeGear.Deployment.Targets CodeGear.Group.Targets CodeGear.Profiles.Targets

 

–jeroen

via [WayBack] QualityCentral: Project compiles fine under IDE, but not using MSBuild.

Posted in Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, QC, Software Development | 3 Comments »

Marking code as obsolete/deprecated in C# and Delphi

Posted by jpluimers on 2015/04/07

During any software life cycle, you will want to phase out some code, and most likely want to mark code to be phased out in the future.

So here are two examples on how to do that in C# and in Delphi that just shows the effects of obsoleting/deprecating code.

Read the rest of this entry »

Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 6, Delphi 7, Delphi 8, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Development, Software Development | 6 Comments »

Interfaces are great, but they can be a pain to debug. Forgetting one weak link can lead to Access Violation hell…

Posted by jpluimers on 2015/03/24

Paul Thornton posted a nice question on G+ two weeks ago:

Interfaces are great, but they can be a pain to debug. Forgetting one weak link can lead to Access Violation hell. I seem to remember a utility that would let you visualise the links between interfaced objects, but can’t remember what it was called. Anybody know?

Do you have any clever interface debugging tips or tricks?

Mixing object and interface references leads to complex situations, especially when some classes make refcounting go away (not limited to UI components) so refactoring is a good idea, it at all possible:

Lars Dybdahl:

Refactor them away :-)

When the mix of interface reference counting and TObject gets so complex, that the source code is no longer obvious, maintenance costs sometimes become too high and another solution might be better.

Nicholas Ring:

 

+Lars Dybdahl Totally agree and it is even worse when reference counting is disabled (like adding an interface reference to an UI component).

 

There is not much tooling, this thread only mentioned RefCountTracer and FastMM:

Steffen Binas:

There is this: https://github.com/AquaSoftGmbH/RefCountTracer

It helps you find memoryleaks, but also could show you if a refcount goes below 0.

Paul Thornton:

This link was very useful. It also points to a good FastMM tutorial.

Which reminded me I totally forgot to post that tutorial on my blog so here it is:

Read the rest of this entry »

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Software Development | 2 Comments »