Recent

Author Topic: (yet another) Forward declaration not solved  (Read 9497 times)

IPguy

  • Sr. Member
  • ****
  • Posts: 385
(yet another) Forward declaration not solved
« on: April 11, 2011, 04:55:24 am »
In my main program I had created a procedure, which works fine.
Now, I need to use that procedure from another unit, so I have to declare that procedure in the class portion of my main form.

Declaration: I added the following line and get the below error.
   Procedure ValidateRegKeyStr(Sender:TObject; RegKey:AnsiString; Out Valid:Boolean);     

In the body of my code, the procedure call looks like this:
Procedure ValidateRegKeyStr(Sender:TObject; RegKey : AnsiString; Out Valid:Boolean);     

I'm getting the following error, which points to the Declaration statement:
RIMMain.pas(166,15) Error: Forward declaration not solved "TfRIMMain.ValidateRegKeyStr(TObject,AnsiString,out Boolean);"

Without the above Declaration, the call to the procedure from the new unit gives the following error:
RegForm.pas(61,17) Error: identifier idents no member "ValidateRegKeyStr"


Any suggestions?
I've rebuild Lazarus-no improvements.
0.9.31-30142-2.4.2, win32-Vista

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: (yet another) Forward declaration not solved
« Reply #1 on: April 11, 2011, 05:00:03 am »
In the body of your code, your procedure needs to appear like this:

Code: [Select]
procedure TfRIMMain.ValidateRegKeyStr(TObject,AnsiString,out Boolean);
begin
{...}
end;

And the declaration needs to be on the public part of the class:

Code: [Select]
public
  procedure ValidateRegKeyStr(TObject,AnsiString,out Boolean);
« Last Edit: April 11, 2011, 05:09:56 am by typo »

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: (yet another) Forward declaration not solved
« Reply #2 on: April 11, 2011, 05:08:55 am »
Type, thank you.
That worked.

I can see why it worked for the 2nd unit, but why would I need to reference the procedure by the form name if both the procedure and the call to it are in the same unit?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: (yet another) Forward declaration not solved
« Reply #3 on: April 11, 2011, 05:13:26 am »
You need to call the procedure with the unit name if there is another procedure with the same name on another unit of your uses.

BTW, forward delcaration not solved means that you have declared something that the compiler could not find.
« Last Edit: April 11, 2011, 05:20:26 am by typo »

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: (yet another) Forward declaration not solved
« Reply #4 on: April 11, 2011, 05:23:50 am »
My presumption on "forward dec...." issues is that I have some sort of inconsistency between the form declaration and the procedure name declaration.  In this case, both were identical. 

I have it working now, so on to solving the next issue.
Thanks again.

 

TinyPortal © 2005-2018