Reputation: 55
Ι am encountering an error in this code:
Result := TempStr;
ShowMessage('test');
Undeclared identifier 'ShowMessage'
Any ideas what I am doing wrong?
Upvotes: 1
Views: 2316
Reputation: 108963
If you look at the documentation, you'll see that the ShowMessage
function is found in the Dialogs
unit.
Therefore, to use the ShowMessage
function in a program or unit, you need to make sure to include the Dialogs
unit in an appropriate uses
clause.
The Dialogs
unit is by default included in GUI forms (both VCL and FMX), so most likely you are creating a new, non-form unit in a GUI application or developing a console application. In either case, you must add the unit yourself.
Here is a console example:
program Error;
{$APPTYPE CONSOLE}
{$R *.res}
uses
SysUtils;
begin
ShowMessage('Test');
end.
becomes
program Solution;
{$APPTYPE CONSOLE}
{$R *.res}
uses
SysUtils, Dialogs;
begin
ShowMessage('Test');
end.
Upvotes: 7