Logical OR operators
Posted: Wed Aug 01, 2018 2:04 pm
Trying to run a former Vulcan App compiled with X# (with Vulcan RUntime of course), I noticed a difference in Logical OR operators.
My App had the code:
LOCAL aStr AS STRING[]
...
IF aStr <> NULL || aStr:Length < 1
...
ENDIF
The X# runtime error is:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
then, I replaced the || with .OR.
IF aStr <> NULL .OR. aStr:Length < 1
...
ENDIF
the error disappeared!
So, if the || operator is used, BOTH conditions are checked.
In contrast, by using the .OR. operator, when the 1st condition is TRUE then the 2nd is ignored.
Is-it the correct operators' behaviour in X#, or the || operator had to behave like the .OR. operator and it's a bug?
regards
George
My App had the code:
LOCAL aStr AS STRING[]
...
IF aStr <> NULL || aStr:Length < 1
...
ENDIF
The X# runtime error is:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
then, I replaced the || with .OR.
IF aStr <> NULL .OR. aStr:Length < 1
...
ENDIF
the error disappeared!
So, if the || operator is used, BOTH conditions are checked.
In contrast, by using the .OR. operator, when the 1st condition is TRUE then the 2nd is ignored.
Is-it the correct operators' behaviour in X#, or the || operator had to behave like the .OR. operator and it's a bug?
regards
George