11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Caché</strong> <strong>ObjectScript</strong> Commandswas created. By default, a SET assigns a global in the current namespace. You can use SETto define a global (^myglobal) in another namespace (samples) by using syntax such as thefollowing: SET ^[“samples”]myglobal="Ansel Adams”.A variable can be a piece or segment of a variable as specified in the argument of a $PIECEor $EXTRACT function.Note that you can assign values to only certain special variables. See the reference pages forindividual special variables for further details.valueA literal value or any valid <strong>Caché</strong> <strong>ObjectScript</strong> expression. Usually a value is a numeric orstring expression.• A numeric value is converted to canonical form before assignment: leading and trailingzeros, a plus sign or a trailing decimal point are removed. Any exponentiation or specifiedarithmetic operations are performed.• A string value is enclosed in quotation marks. A string is assigned unchanged, exceptthat doubled quotation marks within the string are converted to a single quotation mark.The null string ("") is a valid value.• A numeric value enclosed in quotation marks is not converted to canonical form and noarithmetic operations are performed before assignment.• If a relational or logical expression is used, <strong>Caché</strong> assigns the truth value (0 or 1) resultingfrom the expression.• Object properties and object methods that return a value are valid expressions. Use the.. syntax for assigning a property or method value to a variable.ExamplesThe following example illustrates how you can specify multiple arguments for the same SETcommand. Specifically, the command assigns values to three variables. note that argumentsare evaluated in left-to-right order.SET var1=12,var2=var1*3,var3=var1+var2WRITE "var1=",var1,!,"var2=",var2,!,"var3=",var3The following example shows the (variable-list)=value form of the SET command. Itshows how to assign the same value to multiple variables. Specifically, the command assignsthe value 0 to three variables.SET (sum,count,average)=0WRITE "sum=",sum,!,"count=",count,!,"average=",average128 <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!