Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi Cannot Identify something alredy declared :/

Status
Not open for further replies.

HelpMEDude

Programmer
Feb 27, 2005
21
SE
Hi, I would need some help with my program I'm doing.

The problem is that when I try to compile/run my project it founds a problem that says:

[Error] Unit1.pas(44): Undeclared identifier: 'L31'

L31 is a label on form1. It is alredy declared as

Var
L31 : TLabel.

I using it in a procedure thats made by myself (its not done by dubbelclicking on an event on the object inspector)

The Procedure look like this:

Procedure Checkcrash;
Begin
IF L31.caption ='>Stone<' and bilplacering1 then CarCrashed;
IF L32.caption ='>Stone<' and bilplacering2 then CarCrashed;
IF L33.caption ='>Stone<' and bilplacering3 then CarCrashed;
IF CarCrashed Then Begin
Crashed.caption:='Crashed';
Timer1.enabled:=false;
end;
end; -- Carcrashed and bilplacering1/2/3 are booleans

Please help me!!!
 
make your Checkcrash procedure a method of the form. like this :


Code:
type
  TForm1 = class(TForm)
    L31 : TLabel;
    L32 : TLabel;
    ...
  private
    { Private declarations }
    CarCrashed : boolean;
    bilplacering1 : boolean;
    ...
    Procedure Checkcrash;
  end;


...

Procedure TForm1.Checkcrash;
Begin
  IF L31.caption ='>Stone<' and bilplacering1 then CarCrashed;
  IF L32.caption ='>Stone<' and bilplacering2 then CarCrashed;
  IF L33.caption ='>Stone<' and bilplacering3 then CarCrashed;
  IF CarCrashed Then Begin
       Crashed.caption:='Crashed';
       Timer1.enabled:=false;
  end;
end;    -- Carcrashed and bilplacering1/2/3 are booleans


cheers

--------------------------------------
What You See Is What You Get
 
Just a code correction:
Code:
IF L31.caption ='>Stone<' and bilplacering1 then CarCrashed;

Code:
Should be written in this way:
IF (L31.caption ='>Stone<') and bilplacering1 then CarCrashed;


KungTure-RX.jpg

//Nordlund
 
mea culpa, I just copy/pasted his code...

retreating :)

[worm]

--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top