11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The num parameter can be a positive number, incrementing the value of the variable, or anegative number, decrementing the value of the variable. If you do not specify an increment,<strong>Caché</strong> uses the default increment of one (1).You can use the $GET function to return the current value of a variable.$INCREMENT performs this increment as an atomic operation, which does not require theuse of the LOCK command.If multiple processes simultaneously increment the same global through $INCREMENT,each process receives a unique, increasing number (or decreasing number if num is negative).In some situations, certain numbers may be skipped due to timing issues. For further detailson using $INCREMENT with global variables, see Using Multi-Dimensional Storage(Globals) in Using <strong>Caché</strong> Multi-Dimensional Storage.<strong>Caché</strong> does not restore the original, non-incremented value if $INCREMENT is in a transactionthat is rolled back.Incrementing Strings$INCREMENT is generally used for incrementing a variable containing a numeric value.However, it does accept a variable containing a string. The following rules apply when using$INCREMENT on a string:• A null string ("") is treated as having a value of zero.• A numeric string ("123" or "+0012.30") is treated as having that numeric value. Thestring is converted to canonical form: leading and trailing zeros and the plus sign areremoved.• A mixed numeric/nonnumeric string ("12AB" or "1,000") is treated as the numeric valueup to the first nonnumeric character and then truncated at that point. (Note that a commais a nonnumeric character.) The resulting numeric substring is converted to canonicalform: leading and trailing zeros and the plus sign are removed.• A nonnumeric string ("ABC" or "$12") is treated as having a value of zero.$INCREMENT• Exponent operations are performed. For example, if strvar="3E2", $INCREMENT treatsit as having a value of 300.• Arithmetic operations are not performed. For example, if strvar="3+7", $INCREMENTwill truncate the string at the plus sign (treating it as a nonnumeric character) and incrementstrvar to 4.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 221

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!