Page 1 of 1

Posted: 28 Aug 2016, 18:28
by sephult
Hi All!

I was wondering if anyone else found issues when trying logical expressions like "and" , "or" ?

Example:
if (value > 12)and(value < 24) = true then begin


I can't seem to figure out why I keep running into problems and it will not enter my condition.
Any guesses?

-s

Posted: 28 Aug 2016, 18:31
by sephult
Well I guess I solved my issue:

FYI

if (value > 12)and(value < 24) = true then begin

should be

if (value > 12)and(value < 24) then begin

because the boolean is assumed and doesn't need to be defined for the condition.

-s

Posted: 28 Aug 2016, 22:40
by ahonoe
That's correct. You also want to enclose the entire conditional part of the statement in parentheses:

if ((value > 12)and(value < 24)) then begin

I've learned that this gives more consistent results.

Posted: 30 Aug 2016, 00:13
by sephult
Thanks ahonoe,

I kept running into this on many times and couldnt figure out why...lol
Glad finally figured out, makes life easier when scripting.

-s

Posted: 01 Sep 2016, 02:30
by shawnb
True & False do not work as expected... Comparing them to conditions compiles clean, but always returns false.

Posted: 01 Sep 2016, 04:40
by shawnb
Oddly, comparing them to 1 and 0 seems to work.
Just not conditions.

Posted: 01 Sep 2016, 12:13
by sephult
I agree shawnb, that's where I was getting confused. I am so used to doing the comparison and defining the result, I didn't expect that a boolean wouldn't need an expected result defined.

-s