I have some old (from 2003) units for a freeware component that don't compile in Delphi 2009 for unicode translation error. Can I disable with a directive the unicode and leave the old ansichar? Thanks.
![]() |
0 |
![]() |
Roberto Colpani wrote: > I have some old (from 2003) units for a freeware component that don't > compile in Delphi 2009 for unicode translation error. Can I disable > with a directive the unicode and leave the old ansichar? Thanks. No. Good reasons why this is have been given and discussed already. Can't you simply recompile the code and adjust it thus that you get rid of the warnings you get? Does the code use assembler (which is of course harder to convert)? You could ansify your code, IOW, change very mention of "string" into "AnsiString", but that will not clear the problem, it will only shift it to another part of your code. The RTL and VCL will still be Unicode. What is the exact error you get? -- Rudy Velthuis (TeamB) http://www.teamb.com "He has the attention span of a lightning bolt." -- Robert Redford
![]() |
0 |
![]() |
> {quote:title=Rudy Velthuis (TeamB) wrote:}{quote} > Roberto Colpani wrote: > > > I have some old (from 2003) units for a freeware component that don't > > compile in Delphi 2009 for unicode translation error. Can I disable > > with a directive the unicode and leave the old ansichar? Thanks. > > No. Good reasons why this is have been given and discussed already. > > Can't you simply recompile the code and adjust it thus that you get rid > of the warnings you get? Does the code use assembler (which is of > course harder to convert)? > > You could ansify your code, IOW, change very mention of "string" into > "AnsiString", but that will not clear the problem, it will only shift > it to another part of your code. The RTL and VCL will still be Unicode. > > What is the exact error you get? > > -- > Rudy Velthuis (TeamB) http://www.teamb.com > > "He has the attention span of a lightning bolt." > -- Robert Redford The error are some incompatibility with some record that use array of Char. Now I have resolved creating a DLL that export the function I needed with Delphi 2007 and then I have linked it on my program written in delphi 2009. Thanks.
![]() |
0 |
![]() |
Roberto Colpani wrote: > The error are some incompatibility with some record that use array of > Char. Now I have resolved creating a DLL that export the function I > needed with Delphi 2007 and then I have linked it on my program > written in delphi 2009. Thanks. That may work, but is usually not necessary (and a big like cracking a nut with a sledgehammer). What is the EXACT error and what is the EXACT code that causes it (please do a simple copy and paste)? -- Rudy Velthuis (TeamB) http://www.teamb.com "In all large corporations, there is a pervasive fear that someone, somewhere is having fun with a computer on company time. Networks help alleviate that fear." -- John C. Dvorak.
![]() |
0 |
![]() |
<Roberto Colpani> wrote in message news:275811@forums.embarcadero.com... > I have some old (from 2003) units for a freeware component > that don't compile in Delphi 2009 for unicode translation error. > Can I disable with a directive the unicode and leave the old > ansichar? No. You will have to update the code to use AnsiString and AnsiChar explicitally, instead of String and Char generically. -- Remy Lebeau (TeamB)
![]() |
0 |
![]() |
> {quote:title=Rudy Velthuis (TeamB) wrote:}{quote} > Roberto Colpani wrote: > > > The error are some incompatibility with some record that use array of > > Char. Now I have resolved creating a DLL that export the function I > > needed with Delphi 2007 and then I have linked it on my program > > written in delphi 2009. Thanks. > > That may work, but is usually not necessary (and a big like cracking a > nut with a sledgehammer). What is the EXACT error and what is the EXACT > code that causes it (please do a simple copy and paste)? > > -- > Rudy Velthuis (TeamB) http://www.teamb.com > > "In all large corporations, there is a pervasive fear that > someone, somewhere is having fun with a computer on company time. > Networks help alleviate that fear." -- John C. Dvorak. The code comes from the Barcode Component Version 1.25 (15.05.2003) Copyright 1998-2003 Andreas Schmidt and friends The line of code that cause the problem is: result := tabelle_39[FindIdx('*')].data + '0'; of that function. function TAsBarcode.Code_39:string; type TCode39 = record c : char; data : array[0..9] of char; chk: shortint; end; const tabelle_39: array[0..43] of TCode39 = ( ( c:'0'; data:'505160605'; chk:0 ), ( c:'1'; data:'605150506'; chk:1 ), ( c:'2'; data:'506150506'; chk:2 ), ( c:'3'; data:'606150505'; chk:3 ), ( c:'4'; data:'505160506'; chk:4 ), ( c:'5'; data:'605160505'; chk:5 ), ( c:'6'; data:'506160505'; chk:6 ), ( c:'7'; data:'505150606'; chk:7 ), ( c:'8'; data:'605150605'; chk:8 ), ( c:'9'; data:'506150605'; chk:9 ), ( c:'A'; data:'605051506'; chk:10), ( c:'B'; data:'506051506'; chk:11), ( c:'C'; data:'606051505'; chk:12), ( c:'D'; data:'505061506'; chk:13), ( c:'E'; data:'605061505'; chk:14), ( c:'F'; data:'506061505'; chk:15), ( c:'G'; data:'505051606'; chk:16), ( c:'H'; data:'605051605'; chk:17), ( c:'I'; data:'506051605'; chk:18), ( c:'J'; data:'505061605'; chk:19), ( c:'K'; data:'605050516'; chk:20), ( c:'L'; data:'506050516'; chk:21), ( c:'M'; data:'606050515'; chk:22), ( c:'N'; data:'505060516'; chk:23), ( c:'O'; data:'605060515'; chk:24), ( c:'P'; data:'506060515'; chk:25), ( c:'Q'; data:'505050616'; chk:26), ( c:'R'; data:'605050615'; chk:27), ( c:'S'; data:'506050615'; chk:28), ( c:'T'; data:'505060615'; chk:29), ( c:'U'; data:'615050506'; chk:30), ( c:'V'; data:'516050506'; chk:31), ( c:'W'; data:'616050505'; chk:32), ( c:'X'; data:'515060506'; chk:33), ( c:'Y'; data:'615060505'; chk:34), ( c:'Z'; data:'516060505'; chk:35), ( c:'-'; data:'515050606'; chk:36), ( c:'.'; data:'615050605'; chk:37), ( c:' '; data:'516050605'; chk:38), ( c:'*'; data:'515060605'; chk:0 ), ( c:'$'; data:'515151505'; chk:39), ( c:'/'; data:'515150515'; chk:40), ( c:'+'; data:'515051515'; chk:41), ( c:'%'; data:'505151515'; chk:42) ); function FindIdx(z:char):integer; var i:integer; begin for i:=0 to High(tabelle_39) do begin if z = tabelle_39[i].c then begin result := i; exit; end; end; result := -1; end; var i, idx : integer; checksum:integer; begin checksum := 0; {Startcode} result := tabelle_39[FindIdx('*')].data + '0'; for i:=1 to Length(FText) do begin idx := FindIdx(FText[i]); if idx < 0 then continue; result := result + tabelle_39[idx].data + '0'; Inc(checksum, tabelle_39[idx].chk); end; {Calculate Checksum Data} if FCheckSum then begin checksum := checksum mod 43; for i:=0 to High(tabelle_39) do if checksum = tabelle_39[i].chk then begin result := result + tabelle_39[i].data + '0'; break; end; end; {Stopcode} result := result + tabelle_39[FindIdx('*')].data; end;
![]() |
0 |
![]() |
Roberto Colpani wrote: > The code comes from the > Barcode Component > Version 1.25 (15.05.2003) > Copyright 1998-2003 Andreas Schmidt and friends > > The line of code that cause the problem is: > > result := tabelle_39[FindIdx('*')].data + '0'; > >of that function. You did not mention the exact error yet. I found it anyway: E2008 Incompatible types Try this: result := string(tabelle_39[FindIdx('*')].data) + '0'; Data is of type "array[0..9] of char", and you can't simply add a char to such a type (hence the error). You must first convert it to a string, which is the type you want anyway. Fixing such simple conversions is IMO better than putting the code in a DLL and calling it from there. -- Rudy Velthuis (TeamB) http://www.teamb.com "The illegal we do immediately. The unconstitutional takes a bit longer." -- Henry Kissinger
![]() |
0 |
![]() |
> {quote:title=Rudy Velthuis (TeamB) wrote:}{quote} > Roberto Colpani wrote: > > > The code comes from the > > Barcode Component > > Version 1.25 (15.05.2003) > > Copyright 1998-2003 Andreas Schmidt and friends > > > > The line of code that cause the problem is: > > > > result := tabelle_39[FindIdx('*')].data + '0'; > > > >of that function. > > You did not mention the exact error yet. I found it anyway: > > E2008 Incompatible types > > Try this: > > result := string(tabelle_39[FindIdx('*')].data) + '0'; > > Data is of type "array[0..9] of char", and you can't simply add a char > to such a type (hence the error). You must first convert it to a > string, which is the type you want anyway. > > Fixing such simple conversions is IMO better than putting the code in a > DLL and calling it from there. > > -- > Rudy Velthuis (TeamB) http://www.teamb.com > > "The illegal we do immediately. The unconstitutional takes a > bit longer." > -- Henry Kissinger Ok, I have correct the source and it's sure a better solution. Thanks very much.
![]() |
0 |
![]() |