Archive for February, 2013

A Penny for Your Thoughts

Tuesday, February 19th, 2013

If you’re a Canadian developer writing POS software, you have probably implemented a Penny Rounding algorithm to deal with the removal of the Canadian Penny from circulation.  An issue with writing such software is ensuring it works with a variety of regional settings, especially if the target machines are not locked down, or require support for multiple languages.

My implementation is as follows:

function PennyRound(Value :Currency) :Currency;
Implements the Canadian Penny Rounding algorithm
to round to a 5 cent value.

  sTemp :string;
  LastDigit :Char;
  sTemp := FloatToStrF(Value,TFloatFormat.ffFixed,15,2);
  LastDigit := sTemp[Length(sTemp)];

  if CharInSet(LastDigit,['2','7']) then
  begin  //round down by subtracting 0.02
    Result := Value - 0.02;
  if CharInSet(LastDigit,['1','6']) then
  begin  //round down by subtracting 0.01
    Result := Value - 0.01;
  if CharInSet(LastDigit,['4','9']) then
  begin  //round up by adding 0.01
    Result := Value + 0.01;
  if CharInSet(LastDigit,['3','8']) then
  begin  //round up by adding 0.02
    Result := Value + 0.02;
  else  //value is already in 5 cent increments
  if CharInSet(LastDigit,['5','0']) then
    Result := Value;

Anyone have a better implementation?

AnyDAC Acquisition

Thursday, February 7th, 2013

While the information available regarding the AnyDAC acquisition is pretty sparse, I find it worrysome.  Perhaps I’m alone on this, but why does a company acquire a competing technology?  I can think of a couple of reasons: 1) the technology is better than what they currently have, or 2) the company that owns the technology is more progressive and so acquiring them early enough prevents having to compete with, and quite possibly lose to them later.  Otherwise, licensing it is a viable option depending on its intended usage.

Marco in his announcement stated that AnyDAC is “considered the best data access library for Delphi”, and “its [dbExpress] features set remained very stable since it was introduced, and the transition to dbExpress IV started in Delphi 2009, was never fully completed.”  I interpret this last statement as an indication that dbExpress has not continued to evolve, and was never completed in over 4 years.  That is a little disturbing since EMBT sells their additional drivers as part of the Enterprise SKU which commands a large price tag.  It’s also scarey in that Delphi’s popularity was largely due to it’s ability to produce first class client/server applications, and then later distributed database applications.  If EMBT fell behind in such core functionality, to the point where they had to buy a third party product to keep pace, what does that say about their direction?  It’s also concerning that the AnyDAC acquisition might very well mean a change to the EULA in the next release due to the additional cost, and the deprecation of DBX.  I’m sure other EMBT partners such as DevArt are thrilled!

Add to that, the acquiring company is apparently suffering financially, raising it’s prices in the new year, laying off staff, etc, and it really makes you wonder why in January they were negotiating a deal with DA-Soft to purchase DA-Soft’s primary product.  The last time this happened they acquired a flaming ape.

I suppose time will tell what this means to the Delphi community.  I personally don’t see it as a positive.  If I wanted to use AnyDAC, all I had to do was buy it.  Now I will very likely be paying for it (Kind of like the “free” HTML Builder 5 you get with Delphi), whether I want it or not, and there is no telling what the customer service, and development direction of Any DAC will be like in the future.  As part of EMBT, it will become EMBT’s.

I Spy…

Thursday, February 7th, 2013

Whenever I take on a new maintenance project I find that sometimes form names do not adhere to a standard naming convention, or it takes a while to get accustomed to the one used.  For that reason, if you encounter a bug, or behaviour that is not desired when running an application outside of the IDE, it is often difficult to figure out what form is active when the error occurs.

An old school way to answer this question is to use Spy++ to get the window class name, which for Delphi forms is the Delphi class name.  Since Spy++ is a Microsoft VC++ application and tool, it doesn’t come with Delphi so I always have to get it from another source.  I recently found this location with multiple versions.  Guess I’m not the only one who still uses this tool!