Lazarus

Other Languages => Italian => Topic started by: sardu on February 02, 2012, 02:13:26 pm

Title: Error: Identifier not found
Post by: sardu on February 02, 2012, 02:13:26 pm
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: [Select]
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.         
Title: Re: Error: Identifier not found
Post by: Arbee on February 02, 2012, 02:39:32 pm
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.
Title: Re: Error: Identifier not found
Post by: sardu on February 02, 2012, 03:07:06 pm
Thanks :)
TinyPortal © 2005-2018