procedure TForm1.Button2Click(Sender: TObject);
begin
showmassage('Create by rihsano');
end;
Delphi reports the following error:
[Error] Unit1.pas(38): Undeclared identifier: 'showmassage'
One more question: what is "undeclared identifier"?
Replace showmassage with ShowMessage (case isn't important, but spelling is!).
"Undeclared identifier" means that Delphi cannot find the declaration that tells it what showmassage is, so it highlights it as an item that hasn't been declared.
Related
I want to replace a TDBNavigator with a button.
I did :
procedure TForm1.Button1Click(Sender: TObject);
begin
DBNavigator2.BtnClick(nbNext);
end;
but I got an error :
[dcc32 Error] Unit1.pas(284): E2010 Incompatible types: 'TNavigateBtn' and 'TNavigateButton'
Please, could anyone tell me how to fix this problem?
Use the full type name TNavigateBtn.nbNext, for example:
DBNavigator2.BtnClick(TNavigateBtn.nbNext);
That happens most probably because you have Data.Bind.Controls unit in your uses clause. This unit declares the same named nbNext member as a part of the TNavigateButton enumeration.
i want to show wait form in my app. but when i want to run i have an error :
procedure TForm1.Button1Click(Sender: TObject);
var
status: TStatusWindowHandle;
begin
status := CreateStatusWindow('Please Wait...');
try
Sleep(2000);
finally
RemoveStatusWindow(status);
end;
end;
[Error] Unit1.pas(27): Undeclared identifier: 'TStatusWindowHandle'
The CreateStatusWindow() function is taken from the answer by #AndreasRejbrant here: What's the easiest way to write a please wait screen with Delphi?.
The TStatusWindowHandle declaration is:
TStatusWindowHandle = type HWND;
The linked answer suggests putting the CreateStatusWindow function including the type declaration into a separate unit. And then include the unit into the uses clause.
This is what should have been done here as well to avoid the compiler error.
I am toying around in Delphi XE6, and add this procedure on a button:
procedure TTabbedForm.btnLoadingClick(Sender: TObject);
var
dlg: Unit2;
begin
dlg := Form2.Create(nil);
Form2.ShowModal();
end;
Delphi gives me the following error while compiling:
[DCC Error] TabbedTemplate.pas(53): E2029 '.' expected but ';' found
[DCC Error] TabbedTemplate.pas(55): E2029 ';' expected but 'BEGIN' found
[DCC Fatal Error] Speelpleintjes.dpr(7): F2063 Could not compile used unit 'TabbedTemplate.pas'
Line 53 being: dlg: Unit2;
Honestly i'm quite puzzled, the syntax seems correct, the procedure is auto generated from the events tab.
Any suggestions?
If Unit2 is another unit in your project (judging by it's name it probably is), it can't be used as a type directly. Units only declare things. That's why the compiler is expecting a . since you can prefix an identifier with the unit's name to direct to a declaration in that specific unit.
To correct this, write dlg: TForm2;
Also it's common practice to call constructors from the class declaration, not a variable so change it to:
dlg := TForm2.Create(nil);
Or use the Form2 variable, which typically will hold an instance of TForm2 already. By default extra forms added to a Delphi project are created hidden, ready for Show or ShowModal.
The code snippet below demonstrates a problem I am having with with text IO and UInt64 type variables in Delphi XE2 recently re-installed from a recent ISO image file - the compile fails with an error message relating to a missing Text.ReadUInt64 function or procedure. If I replace the failing line with
ReadLn(F,A);
then the program compiles, correctly writes
-1
18446744073709551615
to the text file, and then (as expected) fails on the second read with an EInOutError: "Invalid Numeric Input". Do I have a corrupt install or has someone failed to write a ReadUInt64 function? The only reference to ReadUInt64 that I can find in help is the following definition:
function ReadUInt64: UInt64; virtual;
in System.Classes.TBinaryReader.ReadUInt64. I'm not sure if this is the 'same' function or, if so, why it is virtual...
I am also a little confused by Help's reference to UInt64. It defines it as:
type UInt64 = Int64;
If this is correct, how does the compiler know to treat an UInt64 differently to an Int64 variable?
procedure TForm1.Button1Click(Sender: TObject);
var
F : TextFile;
A : Int64;
B : Uint64;
begin
{
Compiler warns on following line with message:
[DCC Warning] Unit1.pas(32): W1012 Constant expression violates subrange bounds
}
A := $FFFFFFFFFFFFFFFF;
B := $FFFFFFFFFFFFFFFF;
AssignFile(F,'test.txt');
ReWrite(F);
Writeln(F,A);
Writeln(F,B);
CloseFile(F);
AssignFile(F,'test.txt');
ReSet(F);
ReadLn(F,A);
{
Fails to compile on following line with message:
[DCC Fatal Error] Unit1.pas(42): E2158 System unit out of date or corrupted: missing 'Text.ReadUInt64'
}
ReadLn(F,B);
CloseFile(F);
end;
See QC102876. This is a known bug, reported as Text.ReadUInt64 missing, with the description:
The compiler generates a call to Text.ReadUInt64, when an UInt64 should be read from a stream. The linker, however, complains that Text.ReadUInt64 is missing.
This issue (bug) is resolved in XE3 (build #17.0.4625.53395), according to QC.
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.
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;