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

PaulMikeKadow@gmail.com

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.

 

  • 0
  • 0
  • 309
  • 9

Comments

Suggestion: Add links in your index to the different sessions. 

Adding links would be a good idea, if someone could show me how to do it automatically.

I have a new NewBie post every week or so and I envision many of them,

each with a growing list of indexes,

So, please show me how I can automate this task?

You can create one post that is just an index and reference this post in each new material.

Then just update this index post once after each new posting

Copy-paste the current index from the previous post and add a new link to the previous post?

There are a number of things I can do, all of which will require more and more time.

But, perhaps I will leave it as it is, how hard is it to just do a search on the desired post?

With an increasing amount of content, it will get harder and hard to find specific posts through the search. 

 

True enough.

Give me some time to think about how to approach and hopefully solve this.

I will take the suggestions given in this post into consideration.

As someone once said, the only thing we lack is imagination. 

And my imagination has been running on empty lately.

Thanks to all who has contributed to this post.

You could just do a link to the search.  If you create the search that you want, such as "Newbie's Corner" and then copy the link, you can insert that one link. 

This is the link I produced: https://community.intersystems.com/search/all/%22NewBie%27s%20Corner%22

And you get the list of all of your newbie posts.  

That link will do a new search each time, so each time you add a new post it will be listed.  

Doug

Douglas, sorry for taking so long to get back to you.

Thanks for your suggestion, I am going to use it.

Use it as it is and hopefully build upon it.