﻿ NewBie's Corner Session 4 The Plus Sign and Concatenation Operators |
Article
· May 24, 2016 2m read

# NewBie's Corner Session 4 The Plus Sign and Concatenation Operators

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

###### 12

Set the variable X to the value of +"ABC"

###### 0

Here, the Set command sets the variable X to +"ABC". Since X is not numeric, the plus sign forces X to be numeric, a zero.  In COS, the plus sign is used in many ways.

###### ABC

So,

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 = "—" ?

Concatenation Operator

Now, be careful not to confuse the Plus Sign operator with the Concatenation operator, the Underscore.

###### My dog's name is Teddy.

As you can see, the underscore concatenated variables X and Y.

Until next time.