Recent

Author Topic: Error: Operator is not overloaded?  (Read 1299 times)

Dan3468298

  • Full Member
  • ***
  • Posts: 131
Error: Operator is not overloaded?
« 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;
MacOS 10.15.5/Lazarus 2.0.10 Build 2020-07-07

JdeHaan

  • Full Member
  • ***
  • Posts: 115
Re: Error: Operator is not overloaded?
« Reply #1 on: August 04, 2020, 03:31:50 pm »
You have to use parenthesis in this case:

  if (Key in ['0'..'9']) or (Key = '') then

Dan3468298

  • Full Member
  • ***
  • Posts: 131
Re: Error: Operator is not overloaded?
« Reply #2 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!
MacOS 10.15.5/Lazarus 2.0.10 Build 2020-07-07

 

TinyPortal © 2005-2018