I'm new to delphi / free pascal and I think I have a concept error, because I'm used to java and maybe you can not think about things in the same way. I hope you can help me.
I am using Lazarus v1.6RC1.
I have a class TControl
in a unit uControl
and a class TRed
in a unit TRed
. The unit uControl
has the unit uRed
in uses. The case TControl
has an attribute called FRed
, whose type is TRed
(it is an instance of TRed
). The fact is that at any given moment, I need to call a procedure of TControl
from TRed
. My intention is to access the instance of TControl
from TRed
, to be able to access their methods, that's something I did in java, but here it does not seem to work. What I am doing is the following:
Class TControl
:
TControl = class(TObject)
procedure procesaEntradaRed(pComando : TComando)
public
FRed : TRed;
Class TRed
:
TRed = class(TObject)
constructor Create(pControl : TControl)
public
FControl : TControl;
When I install TRed
in TControl
I do it like this:
FRed := TRed.Create(Self);
And the constructor of TRed
is like this:
constructor TRed.Create(pControl : TControl)
begin
FControl := pControl;
end;
The call where I have the error is this:
FControl.procesaEntradaRed(lComando);
The error message is as follows:
uRed.pas (662.12) Error: identifier idents no member "processEntradaRed"
I tried to see which methods were visible from TControl
from TRed
, and none of the ones I created in TControl
is visible, although I did the methods proper to TObject
.
I have only put the parts of the code that intervene in the problem to be concise.
Thanks in advance and sorry for the inexperience.
EDIT:
The line where I make the call is in uRed
, at the end of a procedure whose declaration is:
procedure TRed.UDPRead(AThread: TIdUDPListenerThread; const AData: TidBytes; ABinding: TIdSocketHandle);
However, when commenting on that line, an error occurs when instantiating TRed, passing Self as a parameter:
FRed := TRed.Create(Self);
The error is as follows:
uControl.pas (146,69) Error: Incompatible type for arg no. 3: Got > > "UCONTROL.TControl", expected "CONTROLS.TControl"
Puts that the parameter 3 fails, it is because I also pass 2 strings, I do not show them so as not to confuse.
The fault seems to be in the Self, but I do not know how to fix it.