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.

System and Other FunctionsThe bit_op values 3, 5, 10 and 12 perform a logical operation on only one of the arguments,but they evaluate both arguments.• bit_op=3 always returns the value of arg1, regardless of the value of arg2.• bit_op=5 returns the value of arg2 when the two arguments have the same data type.However if one argument is a string and the other argument is an integer (or signed string)results are unpredictable. If arg2 is the null string $ZBOOLEAN always returns the literalvalue of arg1.• bit_op=10 returns the one's complement value of arg2 if both arguments are integers. Ifarg1 is a string, the operation returns a high order character for each character in arg1..If arg2 is a string, and arg1 is an integer, the bitwise operation is performed on the arg2string. If arg2 is the null string $ZBOOLEAN always returns the literal value of arg1.• bit_op=12 returns the one's complement value of arg1 if it is an integer (or signed string),for any value of arg2 except the null string. If arg1 is a string, the operation returns theone's complement (as a hex value) of each character in arg1. If arg2 is the null string$ZBOOLEAN always returns the literal value of arg1.ExamplesThe following three examples all illustrate the same AND operation. These examples ANDthe ASCII values of lowercase letters with the ASCII value of the underscore character,resulting in the ASCII values of the corresponding uppercase letters.WRITE $ZBOOLEAN("abcd","_",1)displays ABCD.The lowercase "a" = [01100001] (ASCII decimal 97)The underscore character "_" = [01011111] (ASCII decimal 95)The uppercase "A" = [01000001] (ASCII decimal 65)The following example performs the same AND operation as the previous example, but usesthe ASCII decimal values of the arguments. The function $ASCII("a") returns the decimalvalue 97 for the first argument:WRITE $ZBOOLEAN($ASCII("a"),95,1)displays 65.The following example performs the same AND operation, using a $CHAR value as thesecond argument:518 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

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

Saved successfully!

Ooh no, something went wrong!