Lazarus

Programming => General => Topic started by: Dan3468298 on August 04, 2020, 03:27:57 pm

Title: Error: Operator is not overloaded?
Post by: Dan3468298 on August 04, 2020, 03:27:57 pm
Specific is error is

Code: Pascal  [Select][+][-]
  1. unit1.pas(158,24) Error: Operator is not overloaded: "Set Of Char" or "Char"
  2.  

Why can't I do an  'or' conditional?

Code: Pascal  [Select][+][-]
  1. procedure TForm1.txtHeightKeyPress(Sender: TObject; var Key: char);
  2. begin
  3.  
  4.   if Key in ['0'..'9'] or Key = '' then
  5.     //allow user input
  6.   else
  7.     Key := #0;
  8.  
  9. end;
Title: Re: Error: Operator is not overloaded?
Post by: JdeHaan on August 04, 2020, 03:31:50 pm
You have to use parenthesis in this case:

  if (Key in ['0'..'9']) or (Key = '') then
Title: Re: Error: Operator is not overloaded?
Post by: Dan3468298 on August 04, 2020, 04:10:27 pm
I had tried that too but it must have been an early morning brain fart typo.  Thanks for the wake up!
TinyPortal © 2005-2018