* * *

Author Topic: Error: Identifier not found  (Read 6164 times)

sardu

  • Newbie
  • Posts: 4
Error: Identifier not found
« 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.         

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: Error: Identifier not found
« Reply #1 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.
1.0/2.6.0  XP SP3 & OS X 10.6.8

sardu

  • Newbie
  • Posts: 4
Re: Error: Identifier not found
« Reply #2 on: February 02, 2012, 03:07:06 pm »
Thanks :)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus