简体   繁体   中英

Can we use boolean operator in Delphi XE2 LiveBinding expression?

I am planning to write a Live Binding source expression for TCheckBox:

SourceExpression = '(Checked = False) and (Enabled = True)'

When execute the code, an exception prompted:

Expected EOF - trailing text in expression

Is Delphi XE2 Live Binding support boolean operator?

No, boolean operators are not supported directly.

From the docu :

You can use the following math symbols in your expressions:

  • Constants: nil True False Pi
  • Arithmetic operators: + - * /
  • Logic operators: = <> < <= > >=
  • Parentheses, (), to change operator precedence.

But you can use the builtin functions IfAll() , IfAny() and IfThen() instead of and , or and not :

SourceExpression := 'IfAll(IfThen(Checked, False, True), Enabled)'

Or you register your own functions .

I tested this 4 XE4, but it should work for XE2 2.

  • A or B : IfAny(A, B)
  • A and B : IfAll(A, B)
  • not A : IfThen(A, False, True)
  • A xor B : IfAll(IfAny(A, B), IfThen(IfAll(A,B), False, True))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM