Skip to content

Toro Cloud Dev Center


Script step icon

Script steps

A script step in Gloop is a code snippet within a Gloop step. Script steps have complete access to the Gloop variables that are available in the service where the script step is inserted. If you have some logic that needs to be executed in your service which can't be provided with the included Gloop steps, you have a few choices:

A sample service using a script step

A sample service using a script step

The example above shows a simple script step (written in Groovy) with a function used to calculate Fibonacci numbers count times. In the screenshot, count is 20. Also from the screenshot, you can see the following:

  • On line 1 of the script step a new function is declared, which is invoked from line 5 and 8.
  • On line 8, the output of the function is being set to a Gloop variable called fibonacciSeries.

The editor for script steps is very similar to the editor used for set expressions.

Script step editor

Script step editor

TORO recommends reading design guidelines to help you write more maintainable, reusable code in Gloop.

Script steps in the service editor

To show or hide script step content in the editor, toggle or untoggle the "Show Script Lines" option from the toolbar's Filter menu.

Script lines in Martini Desktop

Script lines in Martini Online

Errors in Script steps

If your script step throws an exception (regardless of whether it was from a syntax error or not, or the language), Gloop will produce a standard Gloop stacktrace, but with an extra suffix telling you the line number where the error occurred in your script step. For example, given the error below, the script at line 2 of the NaughtyScript service had an error at line 7 of the script itself:

1
2
io.toro.gloop.exception.GloopException: groovy.lang.MissingPropertyException: No such property: error for class: Script1
    at NaughtyScript.Script(NaughtyScript.gloop:2)[7]

Note the second line in the stacktrace, below, which also has some extra notes on the line underneath:

1
2
3
at NaughtyScrip.Script(NaughtyScript.gloop:2)[7]
-----------------------------------------------------------------
                      |     Service   | Script Line Number

Here is a screenshot showing the script step:

A script step with error

A script step with error

Errors in script steps

Exceptions can be thrown at runtime if your script step has a syntax error. Like any other exception, they will be caught by any parent block steps with a catch.