Hello world!
While practicing to run a procedure from another unit I got this error:
Compilar proyecto, Objetivo: ValeryTweaks.exe: Código de salida 1, Errores: 1, Sugerencias: 1
ufrmmenu.pas(29,15) Error: Forward declaration not solved "Info(AnsiString);"
ufrmmenu.pas(9,15) Hint: Unit "uToolbox" not used in uFRMmenu
I create a unit named: "uToolbox"
and there in the "implementation" I wrote this complex procedure:
Procedure Info(Mensaje : String);
begin
ShowMessage(Mensaje);
end;
In the Form(Unit) named: uFRMmenu where I want to invoke it I:
- Include the uToolbox unit identifier in the uses clause
- Add the procedure header in the "interface > type" section of the Form(Unit) whose invoke the procedure
Then in the clic event of a button in the form that invokes call the procedure like this:
Info('Mensaje de procedimiento de otra unidad');
And I got the error message showed above
When the error is generated the ide stops the compilation in the line of the interface> type section where I include the header of the procedure that I tried to invoke:
interface
uses
uFRMdatabase, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ExtCtrls,
StdCtrls, uToolbox;
type
{ TFRMmenu }
TFRMmenu = class(TForm)
btnTestAnything: TButton;
MainMenu: TMainMenu;
MenuItem1: TMenuItem;
MNUutilidades: TMenuItem;
MNUconexion: TMenuItem;
MNUsalir: TMenuItem;
TimerTransparencia: TTimer;
procedure btnTestAnythingClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure MNUconexionClick(Sender: TObject);
procedure MNUsalirClick(Sender: TObject);
procedure TimerTransparenciaTimer(Sender: TObject);
Procedure Info(Mensaje : String); // <<<<<< HERE THE COMPILATION CRASHES
I leave the complete code of the two units:
unit uToolbox;
{$mode objfpc}{$H+}
interface
uses
Forms, Dialogs, LCLType, Classes, SysUtils;
implementation
Procedure Info(Mensaje : String);
begin
ShowMessage(Mensaje);
end;
//Procedure Info(Mensaje, Titulo : PChar);
//begin
// Application.MessageBox(Mensaje, Titulo, MB_ICONINFORMATION + MB_OK);
//end;
end.
unit uFRMmenu;
{$mode objfpc}{$H+}
interface
uses
uFRMdatabase, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ExtCtrls,
StdCtrls, uToolbox;
type
{ TFRMmenu }
TFRMmenu = class(TForm)
btnTestAnything: TButton;
MainMenu: TMainMenu;
MenuItem1: TMenuItem;
MNUutilidades: TMenuItem;
MNUconexion: TMenuItem;
MNUsalir: TMenuItem;
TimerTransparencia: TTimer;
procedure btnTestAnythingClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure MNUconexionClick(Sender: TObject);
procedure MNUsalirClick(Sender: TObject);
procedure TimerTransparenciaTimer(Sender: TObject);
Procedure Info(Mensaje : String); // <<<<<< HERE THE COMPILATION CRASHES
//Procedure Info(Mensaje, Titulo : PChar);
private
public
end;
var
FRMmenu: TFRMmenu;
implementation
{$R *.lfm}
{ TFRMmenu }
procedure TFRMmenu.TimerTransparenciaTimer(Sender: TObject);
begin
if FRMmenu.AlphaBlendValue < 255 then
begin
FRMmenu.AlphaBlendValue:= FRMmenu.AlphaBlendValue + 3;
end
Else
begin
TimerTransparencia.Enabled:=False;
end
end;
procedure TFRMmenu.MNUsalirClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TFRMmenu.MNUconexionClick(Sender: TObject);
begin
frmDatabase.ShowModal;
end;
procedure TFRMmenu.btnTestAnythingClick(Sender: TObject);
begin
Info('Mensaje de procedimiento de otra unidad');
//Info('Mensaje del dialogo', 'Titulo del dialogo');
end;
procedure TFRMmenu.FormCreate(Sender: TObject);
begin
If Not FileExists(ExtractFileDir(ParamStr(0)) + '\Config.ini') then ShowMessage('El archivo de configuracion no existe!')
else ShowMessage('El archivo de configurcion Config.ini se encuentra en el mismo directorio del ejecutable de la aplicacion.');
end;
end.
I really appreciate any guidance, I really have no idea.