Recent

Author Topic: Error: Forward declaration not solved "Info(AnsiString);"  (Read 2172 times)

Wladimir Kowtun

  • New member
  • *
  • Posts: 7
Hello world!

While practicing to run a procedure from another unit I got this error:

Quote
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:

Code: Pascal  [Select][+][-]
  1. Procedure Info(Mensaje : String);
  2. begin
  3.      ShowMessage(Mensaje);
  4. end;
  5.  

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:

Code: Pascal  [Select][+][-]
  1. Info('Mensaje de procedimiento de otra unidad');
  2.  

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:

Code: Pascal  [Select][+][-]
  1. interface
  2.  
  3. uses
  4.     uFRMdatabase, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ExtCtrls,
  5.     StdCtrls, uToolbox;
  6.  
  7. type
  8.  
  9.   { TFRMmenu }
  10.  
  11.   TFRMmenu = class(TForm)
  12.     btnTestAnything: TButton;
  13.     MainMenu: TMainMenu;
  14.     MenuItem1: TMenuItem;
  15.     MNUutilidades: TMenuItem;
  16.     MNUconexion: TMenuItem;
  17.     MNUsalir: TMenuItem;
  18.     TimerTransparencia: TTimer;
  19.     procedure btnTestAnythingClick(Sender: TObject);
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure MNUconexionClick(Sender: TObject);
  22.     procedure MNUsalirClick(Sender: TObject);
  23.     procedure TimerTransparenciaTimer(Sender: TObject);
  24.  
  25.     Procedure Info(Mensaje : String); // <<<<<< HERE THE COMPILATION CRASHES
  26.  


I leave the complete code of the two units:


Code: Pascal  [Select][+][-]
  1. unit uToolbox;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Forms, Dialogs, LCLType, Classes, SysUtils;
  9.  
  10. implementation
  11.  
  12. Procedure Info(Mensaje : String);
  13. begin
  14.      ShowMessage(Mensaje);
  15. end;
  16.  
  17. //Procedure Info(Mensaje, Titulo : PChar);
  18. //begin
  19. //     Application.MessageBox(Mensaje, Titulo, MB_ICONINFORMATION + MB_OK);
  20. //end;
  21.  
  22.  
  23. end.
  24.  


Code: Pascal  [Select][+][-]
  1. unit uFRMmenu;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.     uFRMdatabase, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ExtCtrls,
  9.     StdCtrls, uToolbox;
  10.  
  11. type
  12.  
  13.   { TFRMmenu }
  14.  
  15.   TFRMmenu = class(TForm)
  16.     btnTestAnything: TButton;
  17.     MainMenu: TMainMenu;
  18.     MenuItem1: TMenuItem;
  19.     MNUutilidades: TMenuItem;
  20.     MNUconexion: TMenuItem;
  21.     MNUsalir: TMenuItem;
  22.     TimerTransparencia: TTimer;
  23.     procedure btnTestAnythingClick(Sender: TObject);
  24.     procedure FormCreate(Sender: TObject);
  25.     procedure MNUconexionClick(Sender: TObject);
  26.     procedure MNUsalirClick(Sender: TObject);
  27.     procedure TimerTransparenciaTimer(Sender: TObject);
  28.  
  29.     Procedure Info(Mensaje : String); // <<<<<< HERE THE COMPILATION CRASHES
  30.  
  31.     //Procedure Info(Mensaje, Titulo : PChar);
  32.  
  33.   private
  34.  
  35.   public
  36.  
  37.   end;
  38.  
  39. var
  40.   FRMmenu: TFRMmenu;
  41.  
  42. implementation
  43.  
  44. {$R *.lfm}
  45.  
  46. { TFRMmenu }
  47.  
  48. procedure TFRMmenu.TimerTransparenciaTimer(Sender: TObject);
  49. begin
  50.   if FRMmenu.AlphaBlendValue < 255 then
  51.     begin
  52.          FRMmenu.AlphaBlendValue:= FRMmenu.AlphaBlendValue + 3;
  53.     end
  54.   Else
  55.     begin
  56.          TimerTransparencia.Enabled:=False;
  57.     end
  58. end;
  59.  
  60. procedure TFRMmenu.MNUsalirClick(Sender: TObject);
  61. begin
  62.   Application.Terminate;
  63. end;
  64.  
  65. procedure TFRMmenu.MNUconexionClick(Sender: TObject);
  66. begin
  67.   frmDatabase.ShowModal;
  68. end;
  69.  
  70. procedure TFRMmenu.btnTestAnythingClick(Sender: TObject);
  71. begin
  72.      Info('Mensaje de procedimiento de otra unidad');
  73.  
  74.      //Info('Mensaje del dialogo', 'Titulo del dialogo');
  75. end;
  76.  
  77. procedure TFRMmenu.FormCreate(Sender: TObject);
  78. begin
  79.   If Not FileExists(ExtractFileDir(ParamStr(0)) + '\Config.ini') then ShowMessage('El archivo de configuracion no existe!')
  80.   else ShowMessage('El archivo de configurcion Config.ini se encuentra en el mismo directorio del ejecutable de la aplicacion.');
  81. end;
  82.  
  83. end.
  84.  


I really appreciate any guidance, I really have no idea.  :(

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Error: Forward declaration not solved "Info(AnsiString);"
« Reply #1 on: May 21, 2021, 04:34:53 pm »
Just remove line 24: Procedure Info(Mensaje : String); // <<<<<< HERE THE COMPILATION CRASHES

Bart

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Error: Forward declaration not solved "Info(AnsiString);"
« Reply #2 on: May 21, 2021, 04:39:52 pm »
Yes, remove it from the interface of uFRMmenu and put it on the interface of uToolBox.

The "interface" declaration must be in the same unit where the function is implemented, otherwise the compiler protests that in the unit where you're actually declaring it (uFRMmenu) there is no actual implementation for it, as you have discovered ;)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Wladimir Kowtun

  • New member
  • *
  • Posts: 7
Re: Error: Forward declaration not solved "Info(AnsiString);"
« Reply #3 on: May 21, 2021, 04:41:17 pm »
Wow thanks for answering so quickly.

I comment on the line you indicated, and now the following error is generated:

Quote
Compilar proyecto, Objetivo: ValeryTweaks.exe: Código de salida 1, Errores: 1
ufrmmenu.pas(72,6) Error: Identifier not found "Info"

In the line where I call the procedure in the event click of the button of the FRMmenu form:

Code: Pascal  [Select][+][-]
  1. Info('Mensaje de procedimiento de otra unidad');  
  2.  

 :-\

Wladimir Kowtun

  • New member
  • *
  • Posts: 7
Re: Error: Forward declaration not solved "Info(AnsiString);"
« Reply #4 on: May 21, 2021, 04:49:36 pm »
Wow thanks for answering so quickly.

I comment on the line you indicated, and now the following error is generated:

Quote
Compilar proyecto, Objetivo: ValeryTweaks.exe: Código de salida 1, Errores: 1
ufrmmenu.pas(72,6) Error: Identifier not found "Info"

In the line where I call the procedure in the event click of the button of the FRMmenu form:

Code: Pascal  [Select][+][-]
  1. Info('Mensaje de procedimiento de otra unidad');  
  2.  

 :-\

Yes!! That was my mistake. I put the declaration in the right place and it executes well.

Thank you for giving me the most precious thing a man has: his time. Really thank you both.  :D

 

TinyPortal © 2005-2018