Best practice when code should still compile with elder versions of Delphi but also Delphi 2009

When tryung to compile Turbopower Orpheus and other Turbopower products 
which I still use in my applications and therefor need to convert to 
Delphi 2009, I get lots of warnings even though others has made it 
possible to get Orpheus compiled.

The problem is checking a char in a set which gives a type cast warning 
and suggests using a new function instead.

[DCC Warning] ovcdbnum.pas(401): W1050 WideChar reduced to byte char in 
set expressions.  Consider using 'CharInSet' function in 'SysUtils' unit.

So what would be the best practice here eg. correcting this routine>

procedure TOvcCustomDbNumberEdit.KeyPress(var Key : Char);
begin
   if AllowIncDec and (Key in ['+', '-']) then
     FDataLink.Edit;

   inherited KeyPress(Key);

   if (Key in [#32..#255]) and (FDataLink.Field <> nil) and
      not FDataLink.Field.IsValidChar(Key) then begin
     MessageBeep(0);
     Key := #0;
   end;

   case Key of
     ^H, ^V, ^X, #32..#255 :
       FDataLink.Edit;
     #27:
       begin
         FDataLink.Reset;
         SelectAll;
         Key := #0;
       end;
   end;
end;

Mark. The change should still work in Delphi 5, Delphi 2006 etc.

In the following case I would think changing the declaration of S would 
help avoiding the warning about

[DCC Warning] ovcdbsed.pas(276): W1058 Implicit string cast with 
potential data loss from 'string' to 'ShortString'

procedure TOvcCustomDbNumberEdit.DataChange(Sender : TObject);
var
   P : Integer;
   S : string[80];
begin
   if FDataLink.Field <> nil then begin
     if FAlignment <> FDataLink.Field.Alignment then begin
       FAlignment := FDataLink.Field.Alignment;
       Text := '';
     end;
     if FDataLink.Field.DataType in NumFieldTypes then begin
       if FFocused and FDataLink.CanModify then
         Text := FDataLink.Field.Text
       else
         Text := FDataLink.Field.DisplayText;
     end else begin
       S := FDataLink.Field.ClassName;
       S[1] := '(';
       P := Pos('Field', S);
       if P > 0 then begin
         S[P] := ')';
         setlength(s,p);
         //S[0] := Char(P);
       end else
         S := Concat(S, ')');
       Text := S;
     end;
   end else begin
     FAlignment := taLeftJustify;
     if csDesigning in ComponentState then
       Text := Name
     else
       Text := '';
   end;
end;

Look forward for some suggestions :-)
0
Alf
5/23/2009 8:56:02 AM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

5 Replies
1618 Views

Similar Articles

[PageSpeed] 30
Get it on Google Play
Get it on Apple App Store

On Sat, 23 May 2009 01:56:02 -0700, Alf Christophersen wrote:

> The problem is checking a char in a set which gives a type cast warning 
> and suggests using a new function instead.

> So what would be the best practice here eg. correcting this routine>

I would write my own version of CharInSet and use an ifdef so that it
is not compiled in D2009.

-- 
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
0
Marc
5/23/2009 2:26:10 PM
Alf Christophersen wrote:

> When tryung to compile Turbopower Orpheus and other Turbopower
> products which I still use in my applications and therefor need to
> convert to Delphi 2009, I get lots of warnings even though others has
> made it possible to get Orpheus compiled.

IME, the best things you can do is to convert all of the code to
Unicode. Orpheus was already converted a few times, by me and by
others. The newest is on SourceForge right now. Perhaps you can use
that version?
-- 
Rudy Velthuis (TeamB)        http://www.teamb.com

"A great many people think they are thinking when they are
 merely rearranging their prejudices." -- William James
0
Rudy
5/23/2009 5:03:43 PM
Rudy Velthuis (TeamB) wrote:
> Alf Christophersen wrote:
> 
>> When tryung to compile Turbopower Orpheus and other Turbopower
>> products which I still use in my applications and therefor need to
>> convert to Delphi 2009, I get lots of warnings even though others has
>> made it possible to get Orpheus compiled.
> 
> IME, the best things you can do is to convert all of the code to
> Unicode. Orpheus was already converted a few times, by me and by
> others. The newest is on SourceForge right now. Perhaps you can use
> that version?

Well, the source I tried to compile that give all the messages. I did 
download from CVS just a day ago :-)

It compiles ok, but thought maybe to correct all those warnings about 
conversion popping up.
Maybe that warning has been turned off ??
0
Alf
5/23/2009 5:24:17 PM
Alf Christophersen wrote:

> Rudy Velthuis (TeamB) wrote:
> > Alf Christophersen wrote:
> > 
> >> When tryung to compile Turbopower Orpheus and other Turbopower
> >> products which I still use in my applications and therefor need to
> >> convert to Delphi 2009, I get lots of warnings even though others
> has >> made it possible to get Orpheus compiled.
> > 
> > IME, the best things you can do is to convert all of the code to
> > Unicode. Orpheus was already converted a few times, by me and by
> > others. The newest is on SourceForge right now. Perhaps you can use
> > that version?
> 
> Well, the source I tried to compile that give all the messages. I did 
> download from CVS just a day ago :-)
> 
> It compiles ok, but thought maybe to correct all those warnings about 
> conversion popping up.
> Maybe that warning has been turned off ??

I didn't try the Orpheus version from CVS yet. 

-- 
Rudy Velthuis (TeamB)        http://www.teamb.com

"A man's only as old as the woman he feels."
 -- Groucho Marx
0
Rudy
5/23/2009 8:33:59 PM
Rudy Velthuis (TeamB) wrote:
> 
> I didn't try the Orpheus version from CVS yet. 
> 
Since that one also was updated a few days ago, I guess it should be the 
same.
0
Alf
5/23/2009 10:48:14 PM
Reply:

Similar Artilces:

Delphi 7 to Delphi 2009 migration
Hello, for migrating a Delphi 7 application to Delphi 2009, I wonder if there is some kind of best practices guide available? For example, general pitfalls to watch out, ... or a tool which analyse the current code base in respect to problems with Delphi 2009. Basically it is a BDE based application accessing a MSSQL database. The only third-party component in use is an ActiveX thingy integrating a reporting engine. Thanks, Thomas At CodeRage 2008 session there is this Migrating your Applications to the Latest Delphi Many developers use Delphi 5, 6, 7, 2005, 2006 ...

Code Porting
Hi people, Basically, I am moving an app from Delphi 5 to Delphi 2009 which is all great (yeah right!) and I am having a couple of issues with some thirdparty components that we have the source code for. Being that I wanted to make the task as easy as possible, I was able to download the component in Delphi 2007 format. I have now managed to port that to 2009 so it compiles only with warnings and no errors. So all is good at this moment. Now I am trying to install the component into the IDE by using the install menu option from the project manager. This is where I run into errors. ...

Is it worth to move my code from Delphi 2009 to Delphi 2010?
Hi guys, we are working on Delphi 2009 till this day because we do not have the time to upgrade our code to the newest version. There is always something more important (features, bugs...) and our code has 2+ million lines. I thought that instead of moving from D2009 to XE7 I could atleast move code to D2010 because it is more or less backward compatible and it shouldn't take me that much of a work. I wanted to ask you about your opinion. Is it a good version to move to? Regards. Dimitrij wrote: > I thought that instead of moving from D2009 to XE7 I could atleast > move ...

Delphi 5 To Delphi 2009
I upgraded to Delphi 2009 from D5. The install says I can install Delphi and/or C++. Delphi installed OK but I see nothing of C++. What am I missing or does my upgrade not include C++? Thanks It depends on what you bought. If you bought Delphi 2009 only, that's what you get. If you bought Delphi 2009 and C++ Builder 2009 you get both. My guess is you got Delphi 2009 only. The simplest way to verify is look your invoice - it should say I would think. You could also go to members.embarcadero.com, login, then click on my registered products. There will be a textual description of...

Delphi 4 to Delphi 2009
Hello, Thanks to all who answered my previous question. That was a great help. And atlast our client agreed to upgrade our delphi version from 4 to Delphi 2009. *Sigh*. But before that, I need to give the estimation and cost regarding the migration to delphi 2009. Can anyone tell me is there any tool to migrate from delphi 4 to delphi 2009 or just I need to compile our Delphi 4 application in Delphi 2009. I have read from the delphi 2009 feature matrix that Delphi 1 through Delphi 2007 import is possible in delphi 2009. But i am not that sure considering the size of our application. ...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

Attempting to compile Delphi 5 code in Delphi XE5 is failing
Greetings All, If I'm not in the correct formum please tell me which one I should be in. Just upgraded to Delphi XE5 and am attempting to compile one of my Delphi 5 projects. I used Interbase Express I use either TDataSource -> TCDSProvider -> TDataSetProvider -> TIBQuery or TDataSource -> TClientDataSet -> TDataSetProvider -> TIBQuery Also used TIBDatabase, TIBTransaction, and TIBStoredProc I open the smallest project I have and click compile and almost immediately I receive this error Checking project dependencies... Compiling CITranEngine.dproj...

How to fix get IP-MAC pairs code below from Delphi 7 to Delphi 2009 ?
How to get All IP - MAC address pairs on local PC by Delphi 2009 ? The Code below can get correct answer on Delphi 7, but get error answer on Delphi 2009. How to fix ? or Are there the better method ? // Delphi 7 (Delphi 2009 failed) // // Get Alll IP-MAC address pairs on local PC // unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; function GetIPMAC: String; const ANY_SIZE = 1; MAX_ADAPTER_ADDRESS_LENGTH = 8; // arb. MAX_INTERFACE_NAME_LEN = 256; { mrapi.h } MAXL...

Best Place to get help on converting Delphi 2007 string to Delphi 2009
Where is the best place to get help on converting Delphi 2007 strings to Delphi 2009? The most common problem getting Delphi 7-Delphi 2007 components to compile seems to be caused by the new Unicode strings in Delphi 2009. It would be great if there was some place to go to get help with this. Maybe there should be a new group for String conversion where developers could ask short questions about conversion. For example: Delphi 7 - Delphi 2007 CharArrayPtr = ^CharArray; CharArray = array[0..MaxInt-1] of Char; Compiles Delphi 2009 CharArrayPtr = ^CharArray; CharArray ...

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

Delphi 2009 compiled code
Hi All How safe is Delphi 2009 compiled code. Can my exe be decompiled? Thanks Godfrey "Godfrey Fletcher" <none> wrote in message news:217291@forums.codegear.com... > > How safe is Delphi 2009 compiled code. Can my exe be decompiled? No different than any other Delphi version, it is easy to extract class and published property names, but otherwise is not going to be decompiled into its original source code or anything close. *Any* executable can be decompiled into assembler level code. -- Wayne Niddery (TeamB) Wayne Niddery schrieb: >...

delphi 2006 code in delphi 2010
hello, is there any option to make delphi 2006 code work in delphi 2010? something like in java IDEs where you can define the code level you like to use? the problem is, that i made a project with 2006 and sent it to my customer. they got 2010 and it compiles fine, but it just doesn't work. it deals with en-/decryption of text, we assumed, that it has something to do with ansi vs. unicode strings... but we cant find the exact position where the error occurs. i am a bit dissapointed, because everywhere i read that the new IDE will always be downwards compatible and so on.. but in ...

converting delphi code to delphi .NET
Hi,I'm looking at converting quite a bit of old delphi code to delphi .NET .  I'm wondering can it be converted to VB.NET for certain ?  Or perhaps there are some unsupported functions etc in delphi and I should keep the code delphi ?  There are about 10,000 lines of code.   Anyone brave enough to take an estimate on how long it would take to convert 10,000 lines ?is going from delphi to delphi.NET smooth ?   Would going to another language cause complications ?Thanks! mike123   Mike123,   Sorry I can not help, however, I have the s...

Delphi 2007 to Delphi 2009 Conversion
CharArrayPtr = ^CharArray; CharArray = array[0..MaxInt-1] of Char; How to convert to Delphi 2009? Bill Bill Miller wrote: > CharArrayPtr = ^CharArray; > CharArray = array[0..MaxInt-1] of Char; > > How to convert to Delphi 2009? > > Bill it depends heavelly on how it is used fearther down in your project and what you want to convert it to. I you want to simple convert the declarations ignoring UNicode altogether then the only think you have to change is the CharArray declaratin from a Char to an AnsiChar eg CharArrayPtr = ^CharArray; CharArray =...

Web resources about - Best practice when code should still compile with elder versions of Delphi but also Delphi 2009 - embarcadero.delphi.general

Admission to practice law - Wikipedia, the free encyclopedia
An admission to practice law , also called admission to the bar in some jurisdictions, is acquired when a lawyer receives a license to practice ...

Bernard Tomic's practice court controversy hosed down by senior Queensland official
... made a spirited defence of the much-maligned world No.17, contesting the latest allegations of poor behaviour at last week's Royal Pines practice ...

Free Tools To Organize Your Law Practice
Technology columnist Jeff Bennion walks you through some great new tools to foster collaboration and to help you be more organized in the new ...

Best Practices: HP Partners with Influencers in Video Campaign
In an effort to drive brand engagement with millennials, HP has created a video series in which it collaborates with social influencers to demonstrate ...

8 Blogging Practices You Need to Start Doing Right Now
It has been three years since I began blogging. It never occurred to me to share my writing with the world until one fateful Sunday morning when ...

A doctor who’s not licensed to practice medicine in the US but is now treating Charlie Sheen’s HIV reportedly ...
... Oz Show" that he had been off his meds for a week and was getting treatment from a physician named Sam Chachoua, who is not licensed to practice ...

Girl And Her Dog Practice Their Cartwheels Together
Submitted by: (via Daily Picks and Flicks ) Tagged: dogs , kids , gymnastics , girls , Video Share on Facebook

Cameron condemns 'conservative religious practices' that isolate women
David Cameron has attacked conservative Islamic practices and treatment of women as he announced a £20m fund to improve English classes for migrants. ...

Allen Austin Enters Cleantech Executive Search With Power & Cleantech Practice
... skills in the emerging renewable energy or technology [&hellip Allen Austin Enters Cleantech Executive Search With Power & Cleantech Practice ...

Learning to build apps is like anything else — it takes practice
These days, coding for mobile is one of the most valuable professional skills you can acquire. If you want in on the action but didn’t spend ...

Resources last updated: 1/19/2016 1:06:29 AM