Scripts mostly will actively query the model or change attributes and values, but they also may return a result. The script engine will - depending on the type of the result - show some feedback to the user.
In case the script returns a single object or an array of objects, they are selected in the model browser. An example:
// find first "Short" that is computed based on causes
finder.find("name", "Short").and("failureRateKind",
Metamodel.safetyModel.FailureRateKind.DERIVED).first();
As you can see, the script "returns" the first found object from a finder result. If there is no found, undefined is returned and there is no feedback. But if an object is found, its selected and revealed in the modle browser.
The script may return multiple elements as well, but it has to be an array:
// find first "Short" that is computed based on causes
finder.find("name", "Short").and("failureRateKind",
Metamodel.safetyModel.FailureRateKind.DERIVED).asArray();
Note: the script engine uses the result of the last statement in the script as result. There is no explicitly return statement.
Hast info: if the script returns a text or string, its presented in a modal dialog.
This way its easy to write query scripts or return results.
Happy scripting.