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 following example shows setting a subscripted global variable in a different namespaceusing extended global reference.ZNSPACE "user"SET ^["samples"]name(1)="fred"ZNSPACE "samples"WRITE ^name(1)SET Command with ObjectsThe following example sets x to the value of an object property:SET x=person.LastNamewhere person is the object reference, and LastName is the object property name. Note thatdot syntax is used in object expressions; a dot is placed between the object reference and theobject property name or object method name.To set a variable with an object property or object method value for the current object, usethe double-dot syntax:SET x=..LastNameFor further details, refer to Object-Specific <strong>ObjectScript</strong> Features in Using <strong>Caché</strong> Objects.When using SET with objects, do not perform multiple assignments. For example, avoidstatements such as:// Avoid this syntax:SET (a.Name,b.Name)=zInstead, issue a separate SET command for each assignment, as shown in the followingexample:SET a.Name=zSET b.Name=zThe following command sets x to the value returned by the object method TotalLines():SET x=invoice.TotalLines()A SET command for objects can take an expression with cascading dot syntax, as shown inthe following examples:SET x=patient.Doctor.Hospital.NameSETIn this example, the patient.Doctor object property references the Hospital object, whichcontains the Name property. Thus, this command sets x to the name of the hospital affiliated<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 129

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

Saved successfully!

Ooh no, something went wrong!