Forum > Italian

Error: Identifier not found

(1/1)

sardu:
Ciao a tutti,
sto cercando di fare un porting su lazarus di un sofware ma spesso mi "pianto" in cose apparentementi banali tipo questa:

Creando un pulsante che chiama una procedura, se questa vuole scrivere nella statusbar mi da l'errore:

/Error: Identifier not found "StatusBar1"

Stesso errore se volessi scrivere in un Tmemo etc.

Cosa mi sono perso?
Grazie per un eventuale aiuto.


--- Code: ---unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
  StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    StatusBar1: TStatusBar;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure Prova();
begin
  StatusBar1.Panels[1].Text := ' Prova ';  //Error: Identifier not found "StatusBar1"
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  StatusBar1.Panels[1].Text := ' Funziona ';
   Prova();
end;

end.         

--- End code ---

Arbee:
Not sure if you understand English ...

StatusBar1 is defined withing TForm1 and you use it in a function that is outside the scope of TForm1, which is why it won't find it.

If you would define a function in the TForm1, called TForm1.Prova(), it will work much better.

sardu:
Thanks :)

Navigation

[0] Message Index

Go to full version