Delphi Version Testing

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa 365 Puzzlers  Calendar 2017

Mensa 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

Borland (now CodeGear) defines unique conditional symbols for each version of Delphi which can be tested at compile time.  The problem is, it's not easy to find out what the values are.  Here's a table:

Version

Conditional Symbol

 Compiler Version

Delphi XE5 VER260 26
Delphi XE4 VER250 25
Delphi XE3 VER240 24
Delphi XE2 VER230 23
Delphi XE VER220 22
Delphi 2010 VER210 21
Delphi 2009 VER200 20
Delphi 2007 for NET VER190 19
Delphi 2007 VER180 and VER185 18 and 18.5
Delphi 2006 VER180 18
Delphi 2005 VER170 17
Delphi 8 VER160 16
Delphi 7 VER150  15
Delphi 6 VER140 14
Delphi 5 VER130 --
Delphi 4 VER120 --
Delphi 3 VER110 --
Delphi 2 VER90 --
Delphi 1 VER80 --

Why do we care?  Once in a while we need to change the source code based on the version of Delphi being used.   Conditional test $IFDEF will let us accomplish this.  For example, Delphi 6 needs a windowed control's  DoubleBuffered property to be turned on to prevent flickering when a TImage is redrawn.  This is not necessary in Delphi 5  (I suspect a D5 "bug" that is "corrected" in D6.)   Here's sample code from of a program currently being developed which  fixes some TTabsheets  to make things right regardless of the compiler version used.

{$IFDEF VER140}   {Delphi6?}
    SimpleSheet.doublebuffered:=true;
    DoubleSheet.doublebuffered:=true;
    ForcedSheet.doublebuffered:=true;
{$ENDIF}

 

Addendum January 23, 2008:  I recently started looking into switching from Delphi Version 5 to a free product, Turbo Delphi Explorer, which is Delphi 2006 with some modest restrictions.    I needed to use the conditional version tests to help account for some of the differences when compiling existing  programs and perhaps to maintain compatibility in the future. 

 

 I found this "wikia page" with a complete listing of compiler conditional defines for Delphi:   http://delphi.wikia.com/wiki/Borland_Compiler_Conditional_Defines so  I record it here for future reference.

 

November 7, 2013: I just acquired Delphi XE5 and will be looking into making programs compile under multiple versions.  The table above has been updated with the conditional symbols for versions from 2007 through XE5 in preparation for the experiment.

 

I also added "Compilerversion" values to the table.  Compilerversion   is a global constant initialized for versions beginning with Delphi 6.  Generating conditional code will be cleaner using this constant because we can test for versions ">=" or "<=" a specific version in a single test.  For example, beginning with XE  (Compiler version 22), the date/time formatting variables previously embedded in the SysUtils unit now exist within a FormatSettings record within SysUtils.  So if your program previously referenced "ThousandsSeparator" for example, it must now reference FormatSettings.ThousandsSeparator.  Here's the code change for our UBigIntsV3 unit  when it is building a large integer string representation with the appropriate thousands separators:

 

 {$IF CompilerVersion<22}
Result[NewPos - 3] := ThousandSeparator;
{$ELSE}
Result[NewPos - 3] := FormatSettings.ThousandSeparator;

{$IFEND}

 

With this change, UBigIntsV3 should compile successfully for all Delphi versions after Delphi 5.   

 

November 24, 2013: It looks like there will be a number of differences between my Delphi 7 and Delphi XE5 versions that can be accommodated using the {$IF} conditional compilation technique  described above.   A new Delphi 7, XE5 differences page has been created to record differences as I find them.   This will be a useful reference for me and perhaps of interest to others upgrading their Delphi.

 

 

 

Created: September 15, 2002

Modified: July 29, 2017

 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2017, Gary Darby    All rights reserved.