I used TurboPascal many years ago, and am now trying to use Lazarus to write a GUI program.
I have created a form TfrmTemp.
On the form, I have included a TEdit control named 'edtSepChar'.
In the body of the code, I have defined a a global variable 'sepChar'.
I want to assign the value of 'edtSepChar' to that variable, using 'edtSepChar.Text'.
When I try to compile, I get message 'Error: Identifier not found "edtSepChar"'
I have tried including the assignment in a procedure and also in the main program, but keep getting the same error.
This is part of my code (I have also attached the full Project/Publish zip file):
type
{ TfrmTemp }
TfrmTemp = class(TForm)
edtSepChar: TEdit;
lblSepChar: TLabel;
var
frmTemp: TfrmTemp;
sepChar: string; //global variable
{ TfrmTemp }
procedure PROC1;
begin
sepChar:='PROC1';
ShowMessage('Value in Proc1 is: ' + sepChar); // This works
end;
procedure PROC2;
begin
sepChar := edtSepChar.Text; // This statement causes error message 'Identifier not found'
ShowMessage('Value in Proc2 is: ' + sepChar);
end;
//MAIN PROGRAM
begin
sepChar := edtSepChar.Text; // This statement causes error message 'Identifier not found'
ShowMessage('Separator in Main Program is: ' + sepChar);
PROC1;
PROC2
end.
I will be very grateful if you can tell me what I am doing wrong, and explain what needs to be changed.
Windows 7 Home Premium SP1 / FPC v3.2.0 / Lazarus IDE v2.0.10 r63526