NewBie's Corner Session 8 Not
NewBie's Corner Session 8 Not
Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.
Click on the Caché Cube in your system tray and select Terminal to try out these commands.
NOT operator ('), single quote or apostrophe
The "NOT" operator reverses the truth-value and is intended for numeric operands, however it can be used on alphanumeric operands.
Set X=1
Write 'X
0
Set X=1
If X Write "True" ; 1 is always true and 0 is always false
True
Set X=0
Write 'X ; X is 0, so "Not X" is 1 or true
1
Set X=1
Write 'X ; X is 1, so "Not X" is 0 or false
0
Set X=0
If 'X Write "True" ; X is 0 so "Not X" is 1
True
Set X=5 ; Any "Non Zero" value is true
If X Write "True"
True
Set X=5
Write 'X ; "Not X", or "Not 5", is 0 or false
0
Set X="1"
If X Write "True" ; 1 is always true even with Alphanumeric text
True
Set X="0"
Write 'X ; X is 0, so "Not X" is 1 even with Alphanumeric
1
Set X="1"
Write 'X ; X is 1, so "Not X" is 0 even with Alphanumeric
0
Set X="0ABC" ; The first numeric is used and the rest is ignored
If 'X Write "True"
True
Set X="5ABC" ; "Not X", or "Not 5", is 0 or false
Write 'X ; The first numeric is used and the rest is ignored
0
Set X="ABC0" ; If the numeric is not the first character the entire string is ignored
If 'X Write "True"
True
I suggest you spend some time on the Terminal trying some of these combinations. They are not always as obvious as you think.
--Mike Kadow
If you have a comment, please respond through the InterSystems Developer Community, don't send my private email. Unless of course you wish to address me only.
See NewBie Index for an index of all NewBie Corner posts.