NewBie's Corner Session 4 The Plus Sign and Concatenation Operators
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 the commands.
Plus Sign (+) operator
Typically, the Plus sign (+) adds two numbers together. This is true in COS (Caché ObjectScript), but COS uses it in other ways as well.
Set the variable X to a value of +12
Set the variable X to the value of +"ABC"
Here, the Set command sets the variable X to +"
Write X ; The actual value of X does not change
if X="ABC" and +X=0,
What does +"5ABC" yield?
If you answered 5 you are right, not 5000, but just 5
Then, what about X = "ABC5", what does +X yield?
Or what about X = "A5376", what does +X yield?
What about X = "", what does +X yield?
X = "—" ?
Now, be careful not to confuse the Plus Sign operator with the Concatenation operator, the Underscore.
Set X="My dog's name is"
Set DOG=X_" "_Y
My dog's name is Teddy.
As you can see, the underscore concatenated variables X and Y.
Until next time.
If you have a comment, please respond through the InterSystems Developer Community, don't send me private email. Unless of course you wish to address me only.
See NewBie Index for an index of all NewBie Corner posts.
“It is not how much you know, but how well you communicate it to others.”