@@ -31,28 +31,28 @@ A list of some common ObjectScript expressions
31
31
| Populate a class | ` Do ##class(package.class).Populate(count, verbose) ` |
32
32
| Remove all objects in process memory | ` Kill ` |
33
33
| 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 ` |
40
40
41
41
## ObjectScript Commands
42
42
43
43
| Command | Description |
44
44
| -------------------------------| -------------------------------------------------------------------------------------|
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 |
56
56
57
57
## ObjectScript Date/Time Functions and Special Variables
58
58
@@ -67,28 +67,28 @@ A list of some common ObjectScript expressions
67
67
68
68
## ObjectScript Branching Functions
69
69
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) ` |
74
74
75
75
## ObjectScript String Functions
76
76
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) ` |
92
92
93
93
## ObjectScript Existence Functions
94
94
@@ -103,13 +103,13 @@ A list of some common ObjectScript expressions
103
103
| Action | Code |
104
104
| --------------------------------------------------| -------------------------------------------------------------|
105
105
| 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) ` |
107
107
| Display random integer from start to start+count | ` Write $random(count) + start ` |
108
108
109
109
## ObjectScript Special Variables
110
110
111
- | Action | Code |
112
- | -------------------------------------------------- | ---------------------- ---------------------------------------|
111
+ | Action | Code |
112
+ | -----------------------------------| ---------------------------------------|
113
113
| Display process ID | ` Write $job ` |
114
114
| Display current namespace | ` Write $namespace ` |
115
115
| Change current namespace | ` Set $namespace = newnamespace ` |
@@ -118,23 +118,23 @@ A list of some common ObjectScript expressions
118
118
119
119
## Utilities
120
120
121
- | Action | Code |
122
- | -------------------------------------------------- | ---------------------- ---------------------------------------|
121
+ | Action | Code |
122
+ | -----------------------------------| ---------------------------------------|
123
123
| Change current namespace | ` Do ^%CD ` <br > ` zn "newnamespace" ` |
124
124
| Display a ^global | ` Do ^%G ` <br > ` zwrite ^global ` |
125
125
126
126
## Collections
127
127
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 |
131
131
| Insert an element at the end of a list | ` Do listObject.Insert(value) ` <br >` Do object.listProperty.Insert(value) ` |
132
132
| Insert an element into a list | ` Do listObject.SetAt(value, position) ` <br >` Do object.listProperty.SetAt(value, position) ` |
133
133
| Remove an element from a list | ` Do listObject.RemoveAt(position) ` <br >` Do object.listProperty.RemoveAt(position) ` |
134
134
| Display an element of a list | ` Write listObject.GetAt(position) ` <br >` Write object.listProperty.GetAt(position) ` |
135
135
| Display the size of a list | ` Write listObject.Count() ` <br >` Write object.listProperty.Count() ` |
136
136
| 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 |
138
138
| Insert an element into an array | ` Do arrayObject.SetAt(value, key) ` <br >` Do object.arrayProperty.SetAt(value, key) ` |
139
139
| Remove an element from an array | ` Do arrayObject.RemoveAt(key) ` <br >` Do object.arrayProperty.RemoveAt(key) ` |
140
140
| 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
143
143
144
144
## Relationships
145
145
146
- | Action | Code |
147
- | -----------------------------------------| ------------------------------------------------------------------------------------------|
146
+ | Action | Code |
147
+ | -----------------------------------------| -------------------------------------------------------------------------------------------------------------- |
148
148
| Parent-to-children object linking | ` Do parentObject.childRefProperty.Insert(chilDobject) ` <br >` Set chilDobject.parentRefProperty = parentObject ` |
149
149
| 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() ` |
156
156
157
157
## Streams
158
158
0 commit comments