Issue with Logical Operators on Strings
Hi all,
I might be losing my mind or do not understand how ObjectScript does string comparisons, but the following does not look right to me.
Is it really possible that you can't compare non-numerical strings other than with an equals or not equals?
USER>w ("45" < "46") 1 USER>w ("45" > "46") 0 USER>w ("V45" < "V46") 0 USER>w ("V45" > "V46") 0 USER>w ("V45" <= "V46") 1 USER>w ("V45" >= "V46") 1
In Python:
>>> print("45" < "46") True >>> print("45" > "46") False >>> print("V45" < "V46") True >>> print("V45" > "V46") False >>> print("V45" <= "V46") True >>> print("V45" >= "V46") False
Product version: Ensemble 2018.1
You need to use the Sorts After operator ]] to do this.
See https://docs.intersystems.com/iris20223/csp/docbook/Doc.View.cls?KEY=GCO...
See String-to-Number Conversion and further.
That is helpful, thank you.
I just find it strange that it is quite non-standard compared to other compilers/interpreters
You have to blame the designers of the language back in the 60ties of last century.
it was even an ANSI Standart then.
And it is backward compatible and the code of the 60ties still can run unchanged!