Recent

Author Topic: <SOLVED> Illegal qualifier?  (Read 23539 times)

undermanager

  • Jr. Member
  • **
  • Posts: 58
<SOLVED> Illegal qualifier?
« on: June 09, 2012, 11:13:13 pm »
I have a very simple form with a button on it and the following code, which gives me an 'Illegal qualifier' message (and the name.Title := 'Mr'; line highlighted) when I try to compile it - and I cannot work out why - any ideas anyone?

var
  frmNames: TfrmNames;

implementation
{$R *.lfm}
uses
  StrUtils;

type fullName = Record
  title : String;
  first : String;
  second : String;
end; {record}

var
  name : fullName;

{ TfrmNames }

procedure TfrmNames.btnSaveNameClick(Sender: TObject);
begin
  name.title:='Mr';
end;


end.
« Last Edit: June 09, 2012, 11:45:08 pm by undermanager »

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Illegal qualifier?
« Reply #1 on: June 09, 2012, 11:32:52 pm »
It is a conflict because "Name" is property of TForm. Rename your variable to "MyName" or whatever.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12776
  • FPC developer.
Re: Illegal qualifier?
« Reply #2 on: June 09, 2012, 11:37:39 pm »
TFrmNames is a class. That class inherits from something (probably a form) that defines "name" as property.

Since the class scope is deeper nested than the unit scope that defines the global variable, The property in the class is accessed, and that doesn't have the field, causing the error.

Solution:

specify you want the name variable in the unit scope, by prefixing it with unitname.  so

Code: [Select]
unitname.name.title:='Mr';
if your unit is called "unitname"

undermanager

  • Jr. Member
  • **
  • Posts: 58
<SOLVED>Re: Illegal qualifier?
« Reply #3 on: June 09, 2012, 11:44:35 pm »
Many thanks. I should have guessed at that!

 :D

 

TinyPortal © 2005-2018