Delphi 5 to Delphi 6 and up

Dear List,

Trying to add 7Zip compression support to my delphi application.
I am using the ported 7Zip sdk (see their website, they have a link).

I am stumped on how to rewrite a single function:

function ReverseDecode(var Models: array of SmallInt; ....): .....

where the input is mostly a fixed size array of SmallInt.
This code perfectly compiles and functions in Delphi 6 and up, but in Delphi 5 I get the error:
There is no overloaded version of 'ReverseDecode' that can be called with these arguments

And obviously, the input (fixed) isn't the same as the param definition (dynamic sized).

However, my question is just as obvious:
How do I rewrite this function so it will behave correctly in Delphi 5? (If this is even possible)

I hope I don't have to overload it to something like:
function ReverseDecode(var Models: array[0..xxx] of SmallInt.......

Thanks in advance for any assistance,
Rory
0
Rory
10/2/2009 11:52:37 AM
embarcadero.delphi.win32 2183 articles. 0 followers. Follow

5 Replies
792 Views

Similar Articles

[PageSpeed] 24

Rory Slegtenhorst wrote:

> Dear List,
> 
> Trying to add 7Zip compression support to my delphi application.
> I am using the ported 7Zip sdk (see their website, they have a link).
> 
> I am stumped on how to rewrite a single function:
> 
> function ReverseDecode(var Models: array of SmallInt; ....): .....
> 
> where the input is mostly a fixed size array of SmallInt.
> This code perfectly compiles and functions in Delphi 6 and up, but in
> Delphi 5 I get the error:  There is no overloaded version of
> 'ReverseDecode' that can be called with these arguments

Is this version of the function part of a set of overloaded versions?
If so, show the others, with full parameter lists please.

> And obviously, the input (fixed) isn't the same as the param
> definition (dynamic sized).

Your parameter is *not* a dynamic array type, it is an open array
parameter. Such a parameter can be passed any variable that is a
fixed-size array of the same base type. It cannot be passed a dynamic
array type in older Delphi versions, like D5 and 6, if memory serves.

> However, my question is just as obvious:
> How do I rewrite this function so it will behave correctly in Delphi
> 5? (If this is even possible)

Insufficient information, see my request above. D5 did have a number of
limitations in the way the compiler handled overloaded
functions/methods, these became progressively less in later versions.

> I hope I don't have to overload it to something like:
> function ReverseDecode(var Models: array[0..xxx] of SmallInt.......

That would not be a valid declaration anyway, you would need a separate
type declaration for the array type.

The low-level approach would be an untyped parameter, but in this case
you must pass the actual size of the array as a separate parameter
since the function would not be able to figure out how much space the
array has on its own.


-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://codenewsfast.com
http://groups.google.com
0
Peter
10/2/2009 5:49:59 PM
Dear Peter,

It is a single function defined as:

function ReverseDecode(var Models: array of smallint; const startIndex:integer;const rangeDecoder:TRangeDecoder; const NumBitLevels:integer):integer;overload;

It then calls this function as

rep0 := rep0 + UBitTreeDecoder.ReverseDecode(m_PosDecoders, rep0 - posSlot - 1, m_RangeDecoder, numDirectBits);

Where
  rep0: Integer // local variable
  posSlot: Integer // local variable
  numDirectBits: Integer // local variable
  m_PosDecoders: array [0..ULZMABase.kNumFullDistances - ULZMABase.kEndPosModelIndex-1] of smallint; //private field of the class calling the function
  m_RangeDecoder:TRangeDecoder; // private field of the class calling the function

At first I thought to be smart, and remove 'var' from Models, but then the decode function doesn't work anymore.

For the time being I have solved this little puzzle by defining the Models parameter as a specific type and by introducing another local variable lArr of that type.
Before and after it calls the function, I copy the data from and to m_PosDecoders/lArr:

definitions:
TSmallIntArray = array of SmallInt;
function ReverseDecode(var Models: TSmallInt; const startIndex:integer;const rangeDecoder:TRangeDecoder; const NumBitLevels:integer):integer;overload;

using it:
SetLength(lArr, SizeOf(m_PosDecoders);
Move(m_PosDecoders[0], lArr[0], SizeOf(m_PosDecoders)); // Copy m_PosDecoders to lArr
rep0 := rep0 + UBitTreeDecoder.ReverseDecode(lArr, rep0 - posSlot - 1, m_RangeDecoder, numDirectBits);
Move(lArr[0], m_PosDecoders[0], SizeOf(m_PosDecoders)); // Copy lArr back to m_PosDecoders
SetLength(lArr, 0);

This compiles in both D5 and D7, in addition that it properly works. This part of the code is vital for proper decoding 7Zip data lol
I am aware of the subtle differences between D5 and D7, but I didn't expect this though.

I truly hope I don't run into a lot of these ;) *grins*

Rory
0
Rory
10/3/2009 4:30:07 PM
Rory Slegtenhorst wrote:

> function ReverseDecode(var Models: array of smallint; const
> startIndex:integer;const rangeDecoder:TRangeDecoder; const
> NumBitLevels:integer):integer;overload;

Hm, yes, that should be valid with the variable declarations you have
shown. So this is likely a D5 limitation. Glad you found a workaround.

-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://codenewsfast.com
http://groups.google.com
0
Peter
10/4/2009 9:01:36 AM
Rory Slegtenhorst wrote:

> 
> It is a single function defined as:
> 
> function ReverseDecode(var Models: array of smallint; const
> startIndex:integer;const rangeDecoder:TRangeDecoder; const
> NumBitLevels:integer):integer;overload;

If it really is just a single function, why is it declared 'overload'? 

I made a small test program in D5, which gives your error message when
'overload' is there, but works as long as 'overload' is not specified. It
looks like overload and open arrays do not work together in D5.

{code}
type
  tArr = array[0..10] of smallint;
var
  iArr: tArr;

procedure IncrementThemOpen(var a: array of smallint); {overload; doesn't
work}
var
  i: Integer;
begin
  for i := Low(a) to High(a) do
    a[i] := a[i] + 1;
end;

procedure IncrementThemFixed(var a: tArr); overload; {fixed array and
overload works}
var
  i: Integer;
begin
  for i := Low(a) to High(a) do
    a[i] := a[i] + 1;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  sl: TStringList;
  i: Integer;
  s: string;
begin
  sl := TStringList.Create;
  sl.CommaText := Edit1.Text;
  for i := 0 to Pred(sl.Count) do begin
    iArr[i] := StrToInt(sl[i]);
  end;

  IncrementThemOpen(iArr);
  IncrementThemFixed(iArr);

  s := IntToStr(iArr[0]);
  for i := 1 to Pred(sl.Count) do begin
    s := s + ', ' + IntToStr(iArr[i]);
  end;
  Edit2.Text := s;
end;{code}

-- 
Anders Isaksson, Sweden
BlockCAD: http://web.telia.com/~u16122508/proglego.htm  
Gallery: http://web.telia.com/~u16122508/gallery/index.htm
0
Anders
10/6/2009 2:29:05 PM
Dear Anders,

> {quote:title=Anders Isaksson wrote:}{quote}
> Rory Slegtenhorst wrote:
> 
> > 
> > It is a single function defined as:
> > 
> > function ReverseDecode(var Models: array of smallint; const
> > startIndex:integer;const rangeDecoder:TRangeDecoder; const
> > NumBitLevels:integer):integer;overload;
> 
> If it really is just a single function, why is it declared 'overload'? 
> 
> I made a small test program in D5, which gives your error message when
> 'overload' is there, but works as long as 'overload' is not specified. It
> looks like overload and open arrays do not work together in D5.

I never even saw the 'overload' directive (out of screen) until it was mentioned a second time here in the thread.
I performed the same tests as you have done, and came to the same conclusion.
Removing 'overload' simply corrected the whole thing.

I am completely unsure as to why the function is declared as such, as it's the only function in the unit.

Thank you very much for your assistance,
Rory
0
Rory
10/9/2009 1:51:52 PM
Reply:

Similar Artilces:

Delphi 5 to Delphi 6 conversion
Hi We are moving our product from D5 to D6. I have dealt with all the deprecated functions. However, we are getting various platform specifc warnings. These include: Symbol 'FileGetAttr' is specific to a platform Symbol 'FileSetAttr' is specific to a platform Symbol 'faReadOnly' is specific to a platform We want this conversion to be carried out correctly. We don't view the simple solution of switching off those warnings or symbols as being the correct way. What we want is the same platform independence as other functions. For example, all o...

Delphi 5 to Delphi XE4
Thinking about making the conversion. Of course we have numerous components such as: TurboPower AsyncPro, TurboPower Orpheus ICS2 Synactis All-In-The-Box. You guys have any advice as to the effort and time it may possibly take. It is a large application, several hundred thousand lines. And that's what happens when using third party components, a lot of extra work. I have been burned a few times. I now minimize the use to a few well known suppliers, like TMS. I have "banned" a lot of other components. Regards, Ole > > Thinking about making the conver...

from delphi 6 to delphi 2010
Hi. It is possible, with component RX, dxforumlibrary, InfoPower3000Pro, StringAlignGrid. Accepts communication BDE. Thank by comments. excequiel arostica wrote: >Hi. > It is possible, with component RX, dxforumlibrary, >InfoPower3000Pro, StringAlignGrid. Accepts communication BDE. > >Thank by comments. Rx is dead and sources are taken over by jcl/jvcl. I dont know about the rest of the components and i have no experiences with bde over the last 9 years. excequiel arostica wrote: > Hi. > It is possible, with component RX, dxforumlibrary,...

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...

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...

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...

ANN: WPTools 6.20 for Delphi 5 to Delphi XE2 & C++Builder
WPTools V6.20 is available now. If you work with Delphi or C++Builder our WPTools Version 6 is the perfect text wordprocessing component for You. It is a native VCL Component with all the editing features which are common to powerful wordprocessing applications and wordprocessing controls. With the PRO and Premium License you get 100% object pascal source. WPTools can be used as a powerful word processor and to create programmatically controlled text. It has a very versatile mail-merge feature which can be enhanced with the "WPReporter addon" to also work with bands. So it ...

Upgrading to Delphi 2009 from Delphi 5
I've decided it's time to upgrade to Delphi 2009 Professional from my current Delphi 5 Professional which (according to the FAQ) makes me eligible for the upgrade pricing. However, I'd just like to clarify how this process works. My concern is that my Delphi 5 is not registered on the CodeGear site and this doesn't seem to be possible as far as I can tell. When installing the trial I noticed that Delphi 2009 registers itself with your CodeGear account so does this mean that the previous version must be registered there to verify you own a Professional edition? I plan to o...

Migration from Delphi 5 to Delphi 2005
Hi, Currently we are using Delphi 5 in that we have lot of source file now we planned to migrate from Delphi 5 to Delphi 2005. My question is - 1. Is it possible to migrate directly from Delphi 5 to Delphi 2005, my old code was developed using Delphi 5 IDE. Can we able to compile and build without any issue in Delphi 2005? 2. If we can able to do then what are the ways to migrate to Delphi 2005 IDE and also provide some link regarding this migrate? Thanks, Rizwan Rizwan Ahmed schrieb: > Hi, Currently we are using Delphi 5 in that we have lot of source > f...

delphi Win32 using delphi .NET dll
Hi, I'm trying to use a delphi.NET dll in delphi.WIN32. I am currently using CodeGear Delphi 2007 with version2(base version) of .NET I can get the dll to import into the WIN32 application the only problem is when i include things such as: "using Classes,DateUtils, SysUtils" in the .NET dll the win32 application will instantly hang when any of the dll functions are called. Any help would be great thanks. Also I have tried this example and it also crashes for me? http://cc.embarcadero.com/Item/22688 -Braden I also found this.. "The problem is that, wehn you instal...

ShareMem Delphi 6 --> Delphi 2009
I have just upgraded from Delphi 6 to Delphi 2009. My software uses about 20 files, plus literally dozens more plug-ins. Every project has ShareMem as its first unit and borlndmm.dll is distributed with the software. I am aware that the Borland Memory Manager was replaced to use FastMM quite some time ago. Will I have to rebuild every EXE and DLL in DElphi 2009 that uses ShareMem, or will supplying the new borlndmm.dll be enough? i.e. I would like to just update the main application EXEs and DLLs, but leave the plug-ins alone. Will this work? Thanks, Jason. -- Jason Sweby ...

Error on Delphi 6 but not on Delphi Xe for Ftp
I am Experimenting with get a file from our webside server via Ftp. I have 2 Machines 1 a laptop runing XP Delphi 6 Indy 10.5.8.0 An a machine runing Window 7 Delphi XE2 with Indy 10.5.8.0. I am using the Same Code on Both. procedure TFrmMain.ProcessItemDalySpecial; var PathDest : String; FileName : String; begin with FrmTb2 do begin if ReadIniBoolean(IniCfg,'FTP','UseFtpDaly') then begin Ftp.Host := ReadIniStr(IniCfg,'FTP','HostDaly'); Ftp.Port := ReadIniInt(IniCfg,'FTP'...

Converting Delphi for Win32 to Delphi .Net(Prism)
Hi, I am currently migrating a project from Delphi for Win32 to Delphi.net. Part of my code currently goes into a directory and pulls out a random file from this directory and loads the contents of the file for me. This code doesn't seem to work in Delphi.Net. It uses PString and a number of functions in SysUtils that don't seem to be present in Delphi.net's SysUtils file. If anyone can help me please, it would be greatly appreciated! Many thanks, Jonathan Mackey Jonathan Mackey a écrit : > I am currently migrating a project from Delphi for Win32 to &...

Delphi.NET loading Delphi.Win32 Driver
Hi, What I'm trying to do is marshal an array of cardinal (or integer) back into managed memory from a win32 dll. I know how to pass managed memory into a win32 dll {code} var aa : array of Integer; Buffer : IntPtr; begin SetLength(aa,2); aa[0] := 1; aa[1] := 80; if not Supports(ExtractFilePath(Application.ExeName)+'Win32_Library\SDK_Driver.Win32.io', TypeOf(IMyFunctions), MyFunctions) then Exit; //loads the driver into memory. MyFunctions contains the method names found in the SDK_Driver. Buffer := Marshal.AllocHGlobal(2 * {Marshal.SystemDefaultC...

Web resources about - Delphi 5 to Delphi 6 and up - embarcadero.delphi.win32

Delphi - Wikipedia, the free encyclopedia
... an archaeological site and a modern town in Greece on the south-western spur of Mount Parnassus in the valley of Phocis . The site of Delphi ...

Delphi Automotive (@DelphiAuto) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Delphi Automotive @ DelphiAuto ...

Delphi Connect for Verizon on the App Store on iTunes
Get Delphi Connect for Verizon on the App Store. See screenshots and ratings, and read customer reviews.


Audi working with Delphi to develop autonomous car tech
Audi is developing an iPad-sized device that will pack all the necessary computing power for a self-driving car

US approves China company's acquisition of Delphi biz
The Committee on Foreign Investment in the United States has formally approved the acquisition of Delphi's global production of braking systems ...

Verizon And Delphi Officially Launch Vehicle Diagnostics Service - $250 For The Module, $5 A Month On ...
If you're a car nut, a paranoid parent, or a small business owner looking to do a little, uh, company vehicle economy analysis, Verizon's teamed ...

Watch out Google: Delphi gives Ars a ride in its self-driving car
The automotive components maker gave Ars a preview ride around the neighborhood. MOUNTAIN VIEW, CA—On Thursday morning I met with Delphi at its ...

The skinny on Delphi's autonomous road trip across the United States
Filed under: Green , Videos , Autonomous Last week, Delphi's autonomous car became the first to complete a coast-to-coast trip across the United ...

Delphi partners with WiTricity on automated wireless charging system
One could easily argue that parking between the white lines at any local hangout presents a challenge for some inexperienced drivers. So, why ...

Resources last updated: 12/6/2015 10:39:20 PM