Get
Returns the properties of arrays and objects output by either a Script function, or another Get function.
Get Overview
The Get function is used to access properties of objects returned by a Script function. It requires a minimum of two arguments: a reference to a Script function, or another Get function that returns an object, or array; and either a string that denotes the property of an object, or a dot-separated path to a property of a sub-object. Optionally, a third argument can be specified to access a zero-based array index, when an array is referenced.
The returned value of the Get function is the value of the property (or indexed array element), and can be any of the following types:
- A number
- True (1) or false (0)
- A string
- A Binary data structure
- A Blob, Edge, Histogram, or Patterns data structure
- A shape object
- An object
- An Image
- Null, undefined or no return statement (which is treated the same as an empty object)
Get Example
For this example, a Script function in cell B3 has a run method that returns an object:
Tool.prototype.run = function(n) { this.updateStats(n); return { total: this._total; stats: { avg: this._avg, range: { max: this._max, min: this._min }, values: this._valueArray } }; };
The following Get functions would return simple numbers (assuming the returned values are numeric):
- Get(B3, "total")
- Get(B3, "stats.avg")
- Get(B3, "stats.range.max")
- Get(B3, "stats.range.min")
The following Get function can return the range sub-object, which could be passed into another Script or Get function:
- Get(B3, "stats.range")
The following Get function can return element 37 from the values array:
- Get(B3, "stats.values", 37)
Get Inputs
|
Script/Get |
Specifies a reference to a Script function or another Get function that returns an Object or Array data structure. |
|
Object Property and/or Array |
Specifies a reference to a property of an Object data structure, either as a string (the name of the property) or a dot-separated path to a property of a sub-object; or an Array data structure. |
|
[Array Index] |
Specifies an optional argument to an index of an array when an Array data structure is referenced. |
Get Outputs
|
Returns |
The function returns the value of the property (or indexed array element), and can return any of the following types:
|