ArrayOutputReturn

arrayOutput~ ArrayOutputReturn

new ArrayOutputReturn(output)

Creates a wrapper for the results produced by ArrayOutput.
This object allows convenient inspection of values, errors and status.

Example

Basic inspection

var { ArrayOutput } = require("sigma/arrayOutput");
var out = new ArrayOutput();

out.add(deviceA, "OK");
out.add(deviceB, null, "Timeout");

var ret = out.getReturn();
print(ret.values());        // ["OK", null]
print(ret.errors());        // [null, "Timeout"]
Parameters:
Array.<Object> output

Internal array with {name, object, value, error} fields.

findObj(obj) → {number}

Return index of the object in the output list.

Example
var index = ret.findObj(deviceA);
if (index >= 0) {
    print("Found at index " + index);
}
Parameters:
Object obj
Returns:
number

get(objopt) → {Array|*|null}

Retrieve all records, or the value for a specific object.

Examples

Get all entries

var all = ret.get();   // returns array of {name, object, value, error}

Get value for one object

var valueA = ret.get(deviceA);
Parameters:
Object obj <optional>
Returns:
Array | * | null

lastError() → {Object|undefined}

Returns the most recent error entry.

Example
var lastErr = ret.lastError();
if (lastErr) {
    print("Last error object = " + lastErr.object);
    print("Error = " + lastErr.error);
}
Returns:
Object | undefined

success() → {boolean}

True if all entries have no error.

Example
if (ret.success()) {
    print("All operations succeeded.");
} else {
    print("Some operations failed.");
}
Returns:
boolean

toString() → {string}

String summary of the result set.

Example
print(ret.toString()); // "ArrayOutputReturn: N elements"
Returns:
string