Search code examples
delphiidentifierself

delphi E2003 undeclared identifier 'self'


I need a bit of help; I'm helping a friend port a Delphi app built years back to newer versions of Windows, as it currently only runs on Windows 95.

The code utilises 3rd party libraries from Woll2Woll for DB operations.

One of these libraries generates the error E2003 Undeclared identifier: 'self'.

I've been through a number of sites via Google and with my limited knowledge of Delphi (stemming from my Pascal training about 12 years ago and extrapolating my slightly rusted PHP, BASH, ColdFusion and ASP coding skills), I've run into a brick wall - I'm strapped for time and can't make sense of the info I'm coming across on the web.

The problematic code segment is from the wwwQuery.pas file and looks like this:

   {$ifdef wwDelphi3Up}
    procedure TwwQuery.OpenCursor(InfoQuery: Boolean);
   {$else}
   procedure TwwQuery.OpenCursor;
   {$endif}
    begin
       {$ifdef wwDelphi3Up}
       inherited OpenCursor(InfoQuery);
       {$else}
       inherited OpenCursor;
       {$endif}
       //Modded by Arie
       //wwSaveAnswerTable(self, Handle, FAnswerTable);
       wwSaveAnswerTable(self, Handle, 'FAnswerTable');
    end;

The precise error messages are:

[DCC Error] wwQuery.pas(243): E2003 Undeclared identifier: 'self'
[DCC Error] wwQuery.pas(244): E2029 '.' expected but ';' found
[DCC Fatal Error] wwcommon.pas(285): F2063 Could not compile used unit 'wwQuery.pas'

Line 243 is the 2nd last line, just above the end;

The wwSaveAnswerTable function looks like this:

Function wwSaveAnswerTable(ADataSet: TDBDataSet; AHandle: HDbiCur; tableName: string): boolean;

What must I change the Self parameter to, to stop the compile error?

Thanks a stack.


Solution

  • The problem is related to compiler define wwDelphi3Up or any related up in code.

    As you see next error message: [DCC Error] wwQuery.pas(244): E2029 '.' expected but ';' found

    Compiler expects end of program, and line wwSaveAnswerTable(self, Handle, 'FAnswerTable'); are not compiled inside OpenCursor method. That's why Self is not defined.

    You don't need to change parameter, because for sure will affect functionality.

    Try to compile it without defines, if you are not use an ancient version of Delphi:

    procedure TwwQuery.OpenCursor(InfoQuery: Boolean);
    begin
       inherited OpenCursor(InfoQuery);
       wwSaveAnswerTable(self, Handle, 'FAnswerTable'); // Here prob FAnswerTable without quotes
    end;