Return

Syntax:

Immediately exit from a script or a macro without generating any error.

return [value]

This command is particularly useful in an object script or in a script file script. The optional return value can only be used when returning from run.section( ), run.file( ), or run.dialog( ) calls.

Note: Macros do not return values. Also, only integer return values from 0 to 255 are supported.

Examples:

Example 1

The following script defines a macro that takes an argument and types OK if the argument is greater than 2. Otherwise, it types Not OK.

def test { 
if (%1 > 2) {
      type "OK";
      return;
}
type "Not OK";  
}

In this case, test 1.876; would respond with Not OK.

Example 2

If an object named Test contains the following script:

if (var1 + 3 * var3 > 1) return 0; 
else return 1;

A script that accesses the object can use the return value as follows:

if (test.run()==0) 
type "Result OK"; 
else type "Result too small";