July 25th, 2012, 12:16 PM
Form can't see components without full path...
Probably a stupid question but I'm stumped...
Why on all my other forms I can...
But on a new form I've just added I have to declare the full path i.e.
label1.caption := 'New Caption';
Without the "form1" it gives an undeclared identifier error? I'm sure this is simple but I'm stumped...
form1.label1.caption := 'New Caption';
July 25th, 2012, 01:37 PM
Note the difference in your procedure header:
As part of your Form Object (assuming form is called Form1)
As declared, ChangeLabelName has no reference to your form, it is in essence a global procedure, not a method of your form. Caption is a property of TForm, which your form is derived from.
So, if you are adding ChangeLabelName as a procedure to your form, you need to add it to your form's declaration (presumably in the private section - unless you want to be able to call it from another form)
After declaring it in the Form's object, you can use the keyboard shortcut Ctrl-Shift-C, and it will add the method's stub into your code.
TForm1 = class(TForm)
Last edited by majlumbo; July 25th, 2012 at 01:44 PM.
July 26th, 2012, 12:24 AM
I believe the first ChangeLabelName procedure is a method of class TForm1. It's accurate declaration should be:
Originally Posted by dlumley
The second one might be an "independent"/"ordinary" procedure or a method of another class.