Machine Learning Quiz (134 Objective Questions) Start ML Quiz

Deep Learning Quiz (205 Objective Questions) Start DL Quiz

Deep Learning Free eBook Download

Wednesday, 25 September 2013

List of Errors and Compiler Warnings while code migration from Delphi 7 to Delphi XE4 - Part 1

List of Errors and Compiler Warnings while code migration from Delphi 7 to Delphi XE4 - Part 1

I had to migrate a Delphi 7 application to the Delphi XE4. While migrating my Delphi 7 application to Delphi XE4, I encountered a lot of compiler errors, warnings and hints. I made a list of all the compiler errors and warning with their solutions which I got during migration from Delphi 7 to Delphi XE4. I think I should share my list and experience with all you Delphi guys. 

Basically, you will get all these compiler errors and warnings when you are migrating the code from your Delphi application which is earlier than Delphi 2009 to Delphi 2009 or the higher versions of Delphi. Most of the errors are related to unicode strings. Delphi 7 does not support unicode because unicode support in Delphi was introduced in Delphi 2009.

Here goes my list of errors and compiler warnings which I got and resolved during Delphi 7 to Delphi XE4 code migration.

1. Mismatched datatypes like AnsiChar / AnsiPChar / AnsiString 

In my Delphi 7 code, a lot of AnsiChar, AnsiPChar and AnsiString keywords were used which were causing problems. So I converted them to WideChar (Char), Unicode String (String) and WidePChar (PChar) for unicoding.

2. Index 0 is not accessible in string

In Delphi 7, there is 0 based string indexing while in Delphi XE4, there is 1 based string indexing. So wherever 0 index of string was used, I had to use 1 index.

3. NoMetadata property does not exist

In Delphi 7, TSQLDataset has property NoMetadata which if set to true, no metadata is loaded. Similar property in Delphi XE4 is GetMetadata which if set to false, no metadata is loaded.

So, I replaced all NoMetaData = True lines to GetMetadata = False and the error got resolved.

4. DBXpress component was not found

DBXpress is deprecated and its functionality is included in SqlExpr. So I removed DBExpress from uses.

5. TMsgDlgBtn enum was causing compilation errors

TMsgDlgBtn enum (Message Dialog) has 12 elements in Delphi XE4 while in Delphi 7, there are only 11 elements. New element is mbClose. So added mbClose in the enums.

6. Shortstring (string[n]) datatypes were throwing errors

Shortstring (string[n]) datatype is deprecated in Delphi XE4 but is there for backward compatibility. So you can still use shortstring in Delphi XE4 but its ANSI not unicode.

I was using firebird 2.5.2 database. I also got some error related to that:

7. %1 is not a valid Win32 application

I had installed 32-bit Delphi XE4 and 64-bit Firebird 2.5. Because of this, I was getting the mentioned error while connecting to the database through Delphi XE4. I uninstalled 64-bit Firebird, downloaded and installed 32-bit Firebird and the problem was resolved. 

8. Following errors were coming in while executing firebird database queries from Delphi XE4

invalid Token
invalid request BLR at offset 163 
function F_ANYFUNCTION is not defined     
module name or entrypoint could not be found

Earlier I was using Firebird 2.5.1. Now I had migrated to Firebird 2.5.2. I looked in the Firebird 2.5.1 configuration file and made similar changes in firebird 2.5.2 configuration file.

ExternalFileAccess = Restrict (path of database file)

Also added udf.dll in UDF folder of Firebird 2.5.2

9. Unknown Driver - DevartInterbase

My Delphi 7 was using DevartInterbase driver in one of the TSQLConnection component. But now when I migrated to Delphi XE4, I was getting the above error. To solve this I downloaded the latest version of devart interbase for Delphi XE4 and the problem was resolved.

10. Unsupported on-disk structure for file mydatabase.fdb

When we installed latest version of devart interbase, by default it was using gds32.dll which is for interbase database. I just replaced VendorLib property of TSQLConnection from gds32.dll with fbclient.dll and the problem was resolved.

11. 'SQLDataSet: Type mismatch for field 'NAME', expecting: String actual:WideString'

When I installed latest devart interbase driver to support Delphi XE4 unicode version, I got this error in TSQLConnection component. 

I found 2 solutions for this error:

A) Set UseUnicode property of TSQLConnection to False.
B) Replace all TStringField with TWideStringField

12. interbase is not licensed

As I downloaded the developer free edition of devart interbase, it was giving this error. To resolve this error, Firebird and Interbase databases have to be restarted every 24 hour. Afterwards I got enterprise edition of devart.

13. Cannot perform operation – DB is not open

While connecting to database, firebird library name and path (fbclient.dll) was missing. Added fbclient.dll path and problem was resolved.

14. “EurekaLog Error” - project post processing has failed

Delphi 7 was using EurekaLog 6. But now I was using EurekaLog 7. So to handle the error, I went in Project –> Eurekalog options –> activated eurekalog and changed project type to old eurekalog application.

Rebuilt and compiled the application and error was gone.

15. When opened Delphi 7 application in Delphi XE4 RAD Studio, I noticed that all the dfm files had changed. The changes which I noticed were like:

Width = 443 --changed in Delphi XE4
Height = 277 --changed in Delphi XE4
ExplicitWidth = 443 --added automatically in Delphi XE4
ExplicitHeight = 277 --added automatically in Delphi XE4

These are the changes which RAD Studio introduces itself in the dfm files when you open it first time. You can ignore these changes or accept it for the first time.

I will come up with more compiler errors and warnings which I got during Delphi 7 to Delphi XE4 code migration in second part of this post.

No comments:

Post a Comment

About the Author

I have more than 10 years of experience in IT industry. Linkedin Profile

I am currently messing up with neural networks in deep learning. I am learning Python, TensorFlow and Keras.

Author: I am an author of a book on deep learning.

Quiz: I run an online quiz on machine learning and deep learning.