0

I have a very old piece of code to handle Excel files in Delphi 5, which I adapted to work with Delphi 2005, which I used professionally until 2010. Since then, there was no reasonable free version of Delphi. Therefore, it is only now that using Delphi 10.2.3 Tokyo I would like to adapt it once again.

A problem that I was not able to solve is related to the use of OleStream.Seek(...) in the function given below, where I get a fatal error with all expressions in OleCheck(...).

Also, I didn't find any hint on a similar problem searching for the function OleStream.Seek(...) on the Internet.

The code is the following

function Streamseek(offset : longint; origin: word):string;
var   
  Pos : longInt ; //  Pos: largeint;
begin
  if FBIFFVersion > biff4 then begin
    case Origin of
      soFromBeginning:
        OleCheck(OStream.Seek(Offset,STREAM_SEEK_SET,Pos));  //  ENUM:  set =0
      soFromCurrent:
        OleCheck(OStream.Seek(Offset,STREAM_SEEK_CUR,Pos));        /// 1 cur
      soFromEnd:
        OleCheck(OStream.Seek(Offset,STREAM_SEEK_END,Pos));        //    2      end
    end;

Of course, it is just one function in a much bigger program, which is not relevant here.

My problem is: I searched for OStream.Seek(Offset,STREAM_SEEK_SET,Pos) on the Internet, but I could only find OleStream.seek(offset : longint; origin: word):string; except for one webpage, but there the same types were used.

Working with IStream in Delphi

So, I wonder what parameter types need to be used.

In the German version of Delphi 10.2.3, I get the error:

[dcc32 Fehler] line(878): E2033 Die Typen der tatsächlichen und formalen Var-Parameter müssen übereinstimmen

In English:

The types of the real and the formal var parameters must be the same.

It is clear that largeint is not a modern parameter type, and I only see the possibility that, instead of Integer, LongInt, Int64 or else is needed since the number of parameters should be OK.

LongInt instead of Integer for offset does not work, Longint instead of LargeInt does not work for pos.

Has anyone an idea what might be the reason for the error? What are the required types of this function in Delphi 10.2.3?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Have you tried simply looking at the actual declaration of `Seek()`? That will tell you exactly which types to use. CTRL-LClick on `Seek()` in the code editor, or RClick on it and choose "Find Declaration". – Remy Lebeau Jul 22 '18 at 19:31
  • Possible dupe of https://stackoverflow.com/questions/3882212/tstream-position-compared-to-tstream-seek? – sgriffin Jul 22 '18 at 19:36
  • Hello,off course it was my first idea to search for the declaration ... but only in the file and myself. So as suggested I used the command find declaration and I found it. Thanks very much.. Sorry for this very easy question but it is my first day after 10 years with Delphi and I never had such a problem before... By the way it was largeUint... – Thommy 7571 Jul 23 '18 at 08:31

0 Answers0