Upgrade to Delphi 6 - Compatibility

zhaozj2021-02-11  199

One. Potential binary FORM file is not compatible

In the past, the binary form file (or DFM file) created by the new version Delphi can be read by the old version of Delphi. But now it is fine. Some binary form files may not be read correctly by the old version because the streaming of the strings inside Delphi 6 is originally different. In the past, fluidization operation assumed a local special character set. Now the new fluidization operation assumes the character set to UTF-8. The problem that caused this is that if the Delphi 6 contains characters that contain the code value greater than 127 (such as copyright index ®) in the binary Form file, the file cannot be read correctly by Delphi's old version.

If you want to open the FORM file of Delphi 6 in the old version of Delphi, please give the Form file as a text format instead of two-in format.

Potential Binary File Incompatibilities

In the past, binary form files (or DFM files) created with newer versions of Delphi could be read by older versions This is no longer true in Delphi 6;. Some binary form files may be read incorrectly because of the way that Delphi 6 performs internal string streaming. In the past, streaming was performed assuming a locale specific character set. Now streaming assumes that the character set is UTF-8. As a consequence, if there are characters with a code greater than 127 (such as the copyright symbol . in a delphi 6 binary form file, That File Cannot Be Read by Older Versions Of Delphi.

IF you intend to use a delphi 6 form File (Including Older Form Files Imported Into and Modified with Delphi 6) in An Older Version of Delphi, The File Should Be Saved In Text Format INSTEAD OF Binary Format.

two. Configurable constant

Compiling Macro $ WriteableConst The current default is changed to off, which is to prevent Delphi's engineering to use the can be assignable constant. The conferred constant is also defined a constant, but it allows it to change its value during operation. The example is as follows:

Const

Foo: integer = 12;

Begin

Foo: = 14;

End.

In the past Delphi version, there is such a characteristic: constant is not true constant. Using the compilation macro $ WRITEABLECONST OFF, the assignment of the FOO between BeGin and End in the above code will trigger a compilation error. To avoid it, simply change the declaration of the foo to VAR.

You may have code that uses constants as a local variable that can be initialized, such as:

PROCEDURE MyProc;

Const

Somedata: integer = 12;

Begin

INC (Somedata, 3);

END;

What you have to do is moved to the external statement of the local constant to the process to make it a global variable. Then the code becomes: VAR

Somedata: integer = 12;

PROCEDURE MyProc;

Begin

INC (Somedata, 3);

END;

For excessive depends on constant codes (such as the Package of the ActiveX control), you can correct it inserted into a {$ WriteableConst on} in the source file. This feature is forbidden in the source code such as RTL, VCL, CLX, and DB, but can be accepted in the package of the periphery, such as the package of the ActiveX control.

All in all, you should realize the contradiction between "can be assigned constant". This feature in Delphi's past release is just to keep with the old 16-bit compiler, but now there is no meaning to Delphi developers. To develop good programming habits, try to avoid the use of mere.

Change in Writeable Constants

.. The $ WRITEABLECONST compiler switch (aka $ J) now has a default state of OFF, which will prevent Delphi projects from having writeable constants Writeable constants refers to the use of a typed constant as a variable modifiable at runtime Here is an example:

Const

Foo: integer = 12;

Begin

Foo: = 14;

End.

In prior releases of Delphi, this was an acceptable construct;.. Constants were not really constant With $ WRITEABLECONST OFF, this code will now produce a compile error on the assignment to the foo variable in the begin..end block To fix it Simply Change The Const Declaration to a var deflaration.

You May Have Code That Uses a Typed Const as an Initialized Local Variable with Global Lifetime, Like this:

PROCEDURE MyProc;

Const

Somedata: integer = 12;

Begin

INC (Somedata, 3);

END;

You will NEED TO MOVE The Local Const Out of the Procedure and Declare It for What It Is: A Global Variable. After Making this Change, The Code Segment Above Becomes:

VAR

Somedata: integer = 12;

PROCEDURE MyProc;

Begin

INC (Somedata, 3);

END;

Code that relies heavily on the typed const quirk (such as the ActiveX control wrapper generator) can insert a {$ WRITEABLECONST ON} directive in the source file as a quick fix. This practice is forbidden in the RTL, VCL, CLX, and DB source code and discouraged in the IDE sources, but acceptable for fringe units such as ActiveX control wrappers.In general, you should note that the phrase "writeable constant" is an oxymoron. Prior versions of Delphi allowed them by default to maintain compatibility with an Older 16-Bit Compiler, Which Is No Longer Important for Most Delphi Developers. Use Good Programming Practice; Avoid Writeable Conntants.

three. Cardinal type negative value

In the past, the 32-bit mechanism was used when Delphi handled the negative value of the Cardinal type, which made the result for some zero-headed values ​​(the maximum value of the Cardinal type and the difference between the current value). The following is an example:

VAR

C: cardinal;

i: int64;

Begin

C: = 4294967294;

I: = -C;

Writeln (i);

END;

In the past version of Delphi, the value of i should be 2. But this value is obviously wrong in this case. In Delphi 6, the Cardinal type is a symbol type that is first converted to 64 bits, then takes its negative value, so the final result i is -4294967294.

There may be an existing code to depends on the implementation method of the original error of the Cardinal negative value. The reader should attract enough attention to this new feature of Delphi. Flowering enough time to verify if your code is used in your code, it is worth it. At the same time, it is sure that this new feature of Delphi does not have an impact on your programs.

UNARY NEGATION OF Cardinal Type

In The Past, Delphi Handled Unary NEGATION OF Cardinal Type Numbers Using 32 Bit Operations, Which Could Lead To Some Odd Results. Here is an Example of Code Which Uses Unary NEGATION:

VAR

C: cardinal;

i: int64;

Begin

C: = 4294967294;

I: = -C;

Writeln (i);

END;

In previous versions of Delphi, the value of i displayed would be 2. This is obviously incorrect behavior for this case. In Delphi 6, the unary negation is handled after promoting the Cardinal type to a 64 bit signed type, so the final value of i displayed is -4294967294.It is possible that existing code may rely on the incorrect behavior of unary negation. Delphi users should be aware of this new behavior. It may be worth your time to check your code for instances of unary negation of Cardinal variables And make Sure That your application responds to the new behavior appropriately.

four. Unit DSGnintf rename and related changes

In the project, I need to update to a new name: DesignIntf. It may be possible to add Designeditors, VCLDITORS, and RTLCONSTS to your reference list. And you have to add Designide to your list of Requires for your package. The reference to DSNIDE 50 may be changed to Designide if Delphi does not automatically change.

Any running period Package that references Idesigner is required to use iDesignerhook to prevent DESIGNIDE when the runtime is used. In the exercise code, Idesignerhook is sufficient to deal with it. The code for designing time can also use iDesigner, but the code should be like the case:

VAR

RealDesigner: Idesigner;

...

Somedesignerhook.QueryInterface (Idesigner, RealDesigner);

...

Get the true Idesigner interface from an instance of Idesignerhook. The use of Idesignerhook only needs to reference Classes and Forms two units. Idesigner also needs to use DesignIntf, which is included in many other Packatgs, and some of them may result in unable to distribute.

Borland hopes to thank the Field tesitor Matt Palcic, thank him for letting us pay attention to it.

DSGnintf Renamed and Related Changes

References to DsgnIntf ​​in your project should be changed to the new Delphi 6 name, DesignIntf. You may also need to add DesignEditors, VCLEditors and RTLConsts to your uses clause. You will also need to add designide to your package's requires list. References to dsnide50 SHOULD probably also be change to designide if this isn't change Automatically by Delphi.

Any runtime packages that use IDesigner need to use IDesignerHook to avoid a requirement of designide at runtime. In runtime code, IDesignerHook should suffice. Design-time code can use IDesigner, but should use something likevar

RealDesigner: Idesigner;

...

Somedesignerhook.QueryInterface (Idesigner, RealDesigner);

...

To get the real IDesigner interface from an instance of IDesignerHook. IDesignerHook only requires Classes and Forms to be available. IDesigner requires DesignIntf, which includes many other packages, some of which may not be redistributable.

Borland Wishes To Than Youk Field Tester Matt Palcic for Bringing these Changes To Our Attention.

Fives. Component editor changes

Delphi 6, class Tcomponiteteditor has different ancestors. In Delphi 5, it from TinterFaceDObject

Inherited; now it is from a new class, TBaseComponiteteditor inherits. At the same time, TcomponenteditorClass has also changed to TBaseComponenteditor class type, not the class type of Tcomponenteditor. These architectural changes may require you to modify your old Delphi project.

Component Editor Changes

The class TComponentEditor has a different ancestry in Delphi 6. In Delphi 5, it from TInterfacedObject descended;. It now descends from a new class, TBaseComponentEditor Also, the class TComponentEditorClass is now a class of TBaseComponentEditor instead of TComponentEditor These changes in hierarchy may. Require you to modify your Older Delphi Projects.

Borland Wishes to Thank Field Tester Clive Walden for Bringing these Changes to outhouse.

转载请注明原文地址:https://www.9cbs.com/read-5345.html

New Post(0)