Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.6d

Application v 6.1b

  

 

Chapter FourFlow Control (continued)

4.11 The ‘return’ Statement

Overview

The return statement causes the execution thread to be passed to the calling function. If there is no calling function, the script exits and returns to its caller which could be the application or another script.

Syntax/Parameters

Syntax

return [parameter];

Parameters

parameter

An optional expression that creates a return value to be returned to the calling routine. If omitted, the function must have been declared as a void type. The return parameter cannot be dimensional.

Remarks

The data type must match the caller’s expectation. If there is a mismatch, this will result in a fatal error and the script terminating.

Use caution returning a handle, if declared as local variable, as they will automatically be released making the returned handle invalid.

To return dimensional data, use the ArrayToCluster function which, in turn, will create a return string. The ClusterToArray function can then be used by the caller to create a dimensional value.

The SetLastError function can be used to return additional information in the event of an error. If a function is called prior to the return statement that sets an error condition, that condition will be returned up the stack to the caller. As such, if the last error buffer is being used, caution and reset the error if necessary by simply using the SetLastError function and setting the value to ERROR_NONE.

When a function is declared as a void data type, the parameter must be omitted. The last closing brace ending a function does not require a ‘return’ statement.

Page revised 2025-08-15