DELPHI PARSER – AUTOMATIC MIGRATION WIZARD

UNIFIED & SIMPLIFIED MIGRATION SCRIPT
USER’S GUIDE

Author: Oren Aviram

Last Update: 1-Sep-2020

Wizard Version: 1.98

Script Version: v7.3

Introduction

The new script version 7.3 includes a migration script from BDE, Interbase TIB, & DB Express Data-Access to FIREDAC.

The new migration script structure is unified & simplified with sections inheritance.

It can contain multi migration scripts in one file, that are easy to read & customize.

The Delphi Parser’s migration script is a human readable text-based script, consisting of [Sections], and commands.

The script is non case sensitive.

The script ignores spaces.

Each script command ends with a line break.

For comments start a line with // or – –

Comments valid for a single line only.

Script Sections

The Delphi Parser Migration Wizard acknowledge several types of Sections.

All sections looks like [SectionName], following by commands.

Sections are bounded by the start of a new section, or by end of file.

Base Sections

Base sections contain the mutual commands for each migration type process, that will be included in every migration process step.

[BaseBDE] – A generic pre-built base script section for migrating BDE to FireDAC

[BaseTIB] – A generic pre-built base script section for migrating TIB (InterBase) to FireDAC

[BaseDBX] – A generic pre-built base script section for migrating DB Express to FireDAC

Section can inherit commands from other sections, which simplify the migration script. Section can inherit commands from many sections, and you can even implement nesting sections. Be careful not to loop nesting sections, because it will lock the process in endless loop.

You can add User-Defined sections, as much as you like, in any name you like, besides the built-in rule-based sections names, and fill them with as many commands you want.

Inherit Command

To make the inheritance use Inherit command.

Syntax: Inherit Section-Name

[SectionA]

— line 1

— line 2

— line 3

[SectionB]

//include SectionA before the lines in SectionB

inherit SectionA

— line 1

— line 2

— line 3

[SectionC]

— Sec line 1

— Sec line 2

— Sec line 3

//include SectionB after the lines in SectionC

inherit SectionB

[SectionD]

— line 1

— line 2

— line 3

[SectionE]

Inherit SectionA

Inherit SectionD

Analysis Section

There are Special Analysis sections, that are not part of the Migration process.

[Analyze]

Performs a Preliminary Scan and Code Analysis.

Included objects will be scanned in the quick scan step.

Migration Process Rule-Based Sections

There are Migration Process Rule Based sections, in which the wizard reads to process each specific migration step.

Pascal Source File Sections:

[ParamVar]

This is a Rule-based script section, that deals with conversion of procedures’ & functions’ parameters variables.

[LocalVar]

This is a Rule-based script section, that deals with conversion of procedures’ & functions’ local variables.

[Global]

This is a Rule-based script section, that deals with global proceduresfunctions variables

[ObjectRef]

This is a Rule-based script section, that deals with conversion of object references in the class declaration.

[DMClassDef]

This is a Rule-based script section, that deals with conversion of Data Module variables through the whole code

[TEMPOBJ]

This is a Rule-based script section, that deals with conversion of temporary objects declarations.

[UNIVERSAL]

This is a Rule-based section, that deals with conversion of legacy Delphi Universal variables members & values that are defined outside of the project code. Usually in the Legacy Delphi Core Class Libraries, like BDE’s Sessions objects.

[AllTypes]

This is a Rule-based section, that performs generic syntax -based text replacements.

Replace only active code.

Ignores Quotes ‘ like this ‘

Ignores Comments (* comment *) and { comment }

[USES]

This is a Rule-based section, for adding & removing specific uses units.

Data Form Modules File Sections:

[DFMOBJECT]

This is the main rule-based section, that deals with converting the DFM files’ objects.

Migration Script Commands

Replace_Object_Type

Description: Replace all objects of a given object’s type name with a new one.

Syntax: Replace_Object_Type , Object Type Name , New Type Name

Example: Replace_Object_Type, TDatabase, TFDConnection

Replace_Member_Name

Description: Looking for all Objects of a given type & will replace its existing object’s member name, with a new member name.

Syntax: Replace_Member_Name, Object-Type name, Existing Member Name, New Member Name

Example: Replace_Member_Name , TDatabase, DatabaseName, Connection

If Object-Type is empty, will look for all kind of objects with the provided existing member name, and will replace with a new member name.

Example: Replace_Member_Name , , DatabaseName, Connection

Replace_Member_Value

Description: Looking for all Objects of a given type, that has a specific member name, checks for existing value & will replace its existing object’s member name, with a new value.

Syntax: Replace_Member_Value, Object-Type Name, Member Name, Existing Value, New Value

Example: Replace_Member_Value, TQuery, UpdateKind, ukModify, arUpdate

Assuming you have the code: “Qry1.UpdateKind := ukModify”, where Qry1 is a TQuery object.

After the conversion it will migrated to: “Query1.updateKind := arUpdate”

If Object-Type is empty, the process will look for all objects, in any type, that has a specific member name.

Example: Replace_Member_Value,, UpdateKind, ukModify, arUpdate

If both Member-Name is empty, will look for all Members, or no member at all, for a given value, and replace with a new value.

Example in DFM:

The Command: Replace_Member_Value, , TransIsolation, tiDirtyRead, xiDirtyRead

Will replace the following line in the DFM:

object Database1: TDatabase

TransIsolation = tiDirtyRead

end

[DFMObject] Section Specific Command

Remove_Object_Member

Description: Looks for a given Object-Type, and will remove (delete from code) the requested object’s member name & its values.

Syntax: Remove_Object_Member, Object-Type, Object Member, Include Child Objects

Object Type: The Name of the Object Type

Object Member: The Name of the Object Member

Include Child Objects: True or False, default True. If True will run through all child objects.

If Object-Type is empty, will look for all objects with a specific member name.

Example: Remove_Object_Member, TQuery, SessionName, False

Example: Remove_Object_Member, , SessionName

BDE Replace Database Name

Description: Will run on all DFM files on projects and replace BDE’s components Database member name and creates new FDConnection if missing in code.

Syntax: Replace_DatabaseName, Data Aware Component, Database Member Name, Old Value,

New Value, Auto Create New Database Connection Component

Example: Replace_DatabaseName, TQuery, DatabaseName, ‘MAST’, MAST, True

This will look for TQuery’s with a DatabaseName member value of ‘MAST’ (as a string including the ‘ ’) and replace with MAST (as object type with no ‘ ’). True – checks if FDConnection object is does not exist on the form, and will create a new one.

Example: Replace_DatabaseName, TQuery, DatabaseName

This will replace any DatabaseName, like ‘MAST’ into MAST, and create new TFDConnection object named MAST if not exist

[AllTypes] Section Specific Commands

Replace

Description: Syntax Based Text Replacment for Pascal files.

Replace only active code.

Ignores Quotes ‘ like this ‘

Ignores Comments (* comment *) and { comment }

Syntax: Replace, Source Text , Target Text

Example: Replace, ShortDateFormat, FormatSettings.ShortDateFormat

[Uses] Section Specific Commands

RemoveUses

Description: Scans PAS files & removes a given unit for the Uses clauses, if exists.

Syntax: RemoveUses, Unit

Example: RemoveUses, DBTables

AddUses

Description: Scan PAS files for a given Object-Type. If the specified Object-Type is found, then adds the List of Units to Uses clause, if missing.

Syntax: AddUses, Object-Type, List of Units to Add separated by comma

Example: AddUses, TFDStoredProc, FireDAC.Stan.Intf, FireDAC.Stan.Option