@@ -31,28 +31,28 @@ A list of some common ObjectScript expressions
3131| Populate a class | ` Do ##class(package.class).Populate(count, verbose) ` |
3232| Remove all objects in process memory | ` Kill ` |
3333| List all objects in process memory | ` Do $system.OBJ.ShowObjects() ` |
34- | Display all properties of an object | ` Do $system.OBJ.Dump(object) ` <br >` Zwrite object ` (v2012.2+) |
35- | Determine If variable is an object reference | ` If $isobject(variable) ; 1=yes, 0=no ` |
36- | Find classname of an object | ` Write $classname(oref) ` |
37- | Start the SQL shell | ` Do $system.SQL.Shell() ` |
38- | Test a class query | ` Do ##class(%ResultSet).RunQuery(class, query) ` |
39- | Declare a variable's type for Studio Assist | ` #dim object as package.class ` |
34+ | Display all properties of an object | ` Do $system.OBJ.Dump(object) ` <br >` Zwrite object ` (v2012.2+) |
35+ | Determine If variable is an object reference | ` If $isobject(variable) ; 1=yes, 0=no ` |
36+ | Find classname of an object | ` Write $classname(oref) ` |
37+ | Start the SQL shell | ` Do $system.SQL.Shell() ` |
38+ | Test a class query | ` Do ##class(%ResultSet).RunQuery(class, query) ` |
39+ | Declare a variable's type for Studio Assist | ` #dim object as package.class ` |
4040
4141## ObjectScript Commands
4242
4343| Command | Description |
4444| -------------------------------| -------------------------------------------------------------------------------------|
45- | ` Write ` | Display text strings, value of variable or expression. |
46- | ` Zwrite ` | Display array, list string, bit string.
47- | ` Set ` | Set value of variable. |
48- | ` Do ` | Execute method, procedure, or routine. |
49- | ` Quit ` or ` Return ` (v2013.1) | Terminate method, procedure, or routine. Optionally return value to calling method. |
50- | ` Continue ` | Stop current loop iteration, and continue looping. |
51- | ` Halt ` | Stop Caché process and close Terminal. |
52- | ` Kill ` | Destroy variable(s). |
53- | ` If {} ElseIf {} Else {} ` | Evaluate conditions and branch. |
54- | ` For {} ` , ` While {} ` , ` Do {} While ` | Execute block of code repeatedly. |
55- | ` Try {} Catch {} ` , ` Throw ` | Handle errors. |
45+ | ` Write ` | Display text strings, value of variable or expression |
46+ | ` Zwrite ` | Display array, list string, bit string |
47+ | ` Set ` | Set value of variable |
48+ | ` Do ` | Execute method, procedure, or routine |
49+ | ` Quit ` or ` Return ` (v2013.1) | Terminate method, procedure, or routine. Optionally return value to calling method |
50+ | ` Continue ` | Stop current loop iteration, and continue looping |
51+ | ` Halt ` | Stop Caché process and close Terminal |
52+ | ` Kill ` | Destroy variable(s) |
53+ | ` If {} ElseIf {} Else {} ` | Evaluate conditions and branch |
54+ | ` For {} ` , ` While {} ` , ` Do {} While ` | Execute block of code repeatedly |
55+ | ` Try {} Catch {} ` , ` Throw ` | Handle errors |
5656
5757## ObjectScript Date/Time Functions and Special Variables
5858
@@ -67,28 +67,28 @@ A list of some common ObjectScript expressions
6767
6868## ObjectScript Branching Functions
6969
70- | Action | Code |
71- | --------------------------------------------------| -------------------------------------------------------------|
72- | Display result for value of expression | ` Write $case(expression, value1:result1, value2:result2, …, :resultN) ` |
73- | Display result for first true condition | ` Write $select(condition1:result1, condition2:result2, …, 1:resultN) ` |
70+ | Action | Code |
71+ | --------------------------------------------------| ------------------------------------------------------------------------ |
72+ | Display result for value of expression | ` Write $case(expression, value1:result1, value2:result2, …, :resultN) ` |
73+ | Display result for first true condition | ` Write $select(condition1:result1, condition2:result2, …, 1:resultN) ` |
7474
7575## ObjectScript String Functions
7676
77- | Action | Code |
78- | --------------------------------------------------| -------------------------------------------------------------|
79- | Display substring extracted from string | ` Write $extract(string, start, end) ` |
80- | Display right-justified string within width characters | ` Write $justify(string, width) ` |
81- | Display length of string | ` Write $length(string) ` |
82- | Display number of delimited pieces in string | ` Write $length(string, delimiter) ` |
83- | Display piece from delimited string | ` Write $piece(string, delimiter, pieceNumber) ` |
84- | Set piece into delimited string | ` Set $piece(string, delimiter, pieceNumber) = piece ` |
85- | Display string after replacing substring | ` Write $replace(string, subString, replaceString) ` |
86- | Display reversed string | ` Write $reverse(string) ` |
87- | Display string after replacing characters | ` Write $translate(string, searchChars, replaceChars) ` |
88- | Build a list | ` Set listString = $listbuild(list items, separated by comma) ` |
89- | Retrieve an item from a list | ` Set variable = $list(listString, position) ` |
90- | Put item into list string | ` Set $list(listString, position) = substring ` |
91- | Display the length of a list | ` Write $listlength(listString) ` |
77+ | Action | Code |
78+ | ---------------------------------------------------------- | -- -------------------------------------------------------------|
79+ | Display substring extracted from string | ` Write $extract(string, start, end) ` |
80+ | Display right-justified string within width characters | ` Write $justify(string, width) ` |
81+ | Display length of string | ` Write $length(string) ` |
82+ | Display number of delimited pieces in string | ` Write $length(string, delimiter) ` |
83+ | Display piece from delimited string | ` Write $piece(string, delimiter, pieceNumber) ` |
84+ | Set piece into delimited string | ` Set $piece(string, delimiter, pieceNumber) = piece ` |
85+ | Display string after replacing substring | ` Write $replace(string, subString, replaceString) ` |
86+ | Display reversed string | ` Write $reverse(string) ` |
87+ | Display string after replacing characters | ` Write $translate(string, searchChars, replaceChars) ` |
88+ | Build a list | ` Set listString = $listbuild(list items, separated by comma) ` |
89+ | Retrieve an item from a list | ` Set variable = $list(listString, position) ` |
90+ | Put item into list string | ` Set $list(listString, position) = substring ` |
91+ | Display the length of a list | ` Write $listlength(listString) ` |
9292
9393## ObjectScript Existence Functions
9494
@@ -103,13 +103,13 @@ A list of some common ObjectScript expressions
103103| Action | Code |
104104| --------------------------------------------------| -------------------------------------------------------------|
105105| Increment ^global by increment | ` $increment(^global, increment) ` <br > ` $sequence(^global, increment) ` |
106- | Match a regular expression | ` Set matches = $match(string, regularexpression) ` |
106+ | Match a regular expression | ` Set matches = $match(string, regularexpression) ` |
107107| Display random integer from start to start+count | ` Write $random(count) + start ` |
108108
109109## ObjectScript Special Variables
110110
111- | Action | Code |
112- | -------------------------------------------------- | ---------------------- ---------------------------------------|
111+ | Action | Code |
112+ | -----------------------------------| ---------------------------------------|
113113| Display process ID | ` Write $job ` |
114114| Display current namespace | ` Write $namespace ` |
115115| Change current namespace | ` Set $namespace = newnamespace ` |
@@ -118,23 +118,23 @@ A list of some common ObjectScript expressions
118118
119119## Utilities
120120
121- | Action | Code |
122- | -------------------------------------------------- | ---------------------- ---------------------------------------|
121+ | Action | Code |
122+ | -----------------------------------| ---------------------------------------|
123123| Change current namespace | ` Do ^%CD ` <br > ` zn "newnamespace" ` |
124124| Display a ^global | ` Do ^%G ` <br > ` zwrite ^global ` |
125125
126126## Collections
127127
128- | Action | Code |
129- | --------------------------------------------------------------| --------------------------------------------------------------------------------------------------------|
130- | Create a new standalone list<br >Work with a list property | ` Set listObject=##class(%ListOfDataTypes).%New() ` <br >Use methods below on a list collection property |
128+ | Action | Code |
129+ | --------------------------------------------------------------| ------------------------------------------------------------------------------------------------------------ |
130+ | Create a new standalone list<br >Work with a list property | ` Set listObject=##class(%ListOfDataTypes).%New() ` <br >Use methods below on a list collection property |
131131| Insert an element at the end of a list | ` Do listObject.Insert(value) ` <br >` Do object.listProperty.Insert(value) ` |
132132| Insert an element into a list | ` Do listObject.SetAt(value, position) ` <br >` Do object.listProperty.SetAt(value, position) ` |
133133| Remove an element from a list | ` Do listObject.RemoveAt(position) ` <br >` Do object.listProperty.RemoveAt(position) ` |
134134| Display an element of a list | ` Write listObject.GetAt(position) ` <br >` Write object.listProperty.GetAt(position) ` |
135135| Display the size of a list | ` Write listObject.Count() ` <br >` Write object.listProperty.Count() ` |
136136| Clear all the elements of a list | ` Do listObject.Clear() ` <br >` Do object.listProperty.Clear() ` |
137- | Create a new standalone array<br >Work with an array property | ` Set arrayObject=##class(%ArrayOfDataTypes).%New() ` <br >Use methods below on an array collection property |
137+ | Create a new standalone array<br >Work with an array property | ` Set arrayObject=##class(%ArrayOfDataTypes).%New() ` <br >Use methods below on an array collection property |
138138| Insert an element into an array | ` Do arrayObject.SetAt(value, key) ` <br >` Do object.arrayProperty.SetAt(value, key) ` |
139139| Remove an element from an array | ` Do arrayObject.RemoveAt(key) ` <br >` Do object.arrayProperty.RemoveAt(key) ` |
140140| Display an element of an array | ` Write arrayObject.GetAt(key) ` <br >` Do object.arrayProperty.GetAt(key) ` |
@@ -143,16 +143,16 @@ A list of some common ObjectScript expressions
143143
144144## Relationships
145145
146- | Action | Code |
147- | -----------------------------------------| ------------------------------------------------------------------------------------------|
146+ | Action | Code |
147+ | -----------------------------------------| -------------------------------------------------------------------------------------------------------------- |
148148| Parent-to-children object linking | ` Do parentObject.childRefProperty.Insert(chilDobject) ` <br >` Set chilDobject.parentRefProperty = parentObject ` |
149149| One-to-many object linking | ` Do oneObject.manyRefProperty.Insert(manyObject) ` <br >` Set manyObject.OneRefProperty = OneObject ` |
150- | Write a property of a child object | ` Write parentObject.childRefProperty.GetAt(position).property ` |
151- | Write a property of a many object | ` Write oneObject.manyRefProperty.GetAt(position).property ` |
152- | Display the count of child/many objects | ` Write parentObject.childRefProperty.Count() ` <br >` Write oneObject.manyRefProperty.Count() ` |
153- | Open a many/child object directly | ` Set object = ##class(package.class).IDKEYOpen(parentID, childsub) ` |
154- | Retrieve the id of a child object | ` Set status = ##class(package.class).IDKEYExists(parentID, childsub, .childID) ` |
155- | Clear the child/many objects | ` Do parentObject.childRefProperty.Clear()<br>Do oneObject.manyRefProperty.Clear() ` |
150+ | Write a property of a child object | ` Write parentObject.childRefProperty.GetAt(position).property ` |
151+ | Write a property of a many object | ` Write oneObject.manyRefProperty.GetAt(position).property ` |
152+ | Display the count of child/many objects | ` Write parentObject.childRefProperty.Count() ` <br >` Write oneObject.manyRefProperty.Count() ` |
153+ | Open a many/child object directly | ` Set object = ##class(package.class).IDKEYOpen(parentID, childsub) ` |
154+ | Retrieve the id of a child object | ` Set status = ##class(package.class).IDKEYExists(parentID, childsub, .childID) ` |
155+ | Clear the child/many objects | ` Do parentObject.childRefProperty.Clear()<br>Do oneObject.manyRefProperty.Clear() ` |
156156
157157## Streams
158158
0 commit comments