Using the Gosu scratchpad

Use the Gosu scratchpad to execute Gosu programs and evaluate Gosu expressions. Instead of needing to perform PolicyCenter operations to trigger your Gosu code, you can run your code directly in the Scratchpad and see immediate results.

Warning: In Studio, Gosu code in the Gosu Scratchpad has different compiler behavior than any other part of Studio. If you run code in Gosu Scratchpad using the Run or Debug buttons, then the code compiles and runs locally in Studio with different behavior. Most notably, the behavior of null safety for properties in the period operator is different. In nearly all other contexts in Studio, the period operator is null safe for properties. However, in Gosu Scratchpad in Studio, Gosu is not null-safe. Code that might not throw an exception in a Gosu class might throw an exception in Gosu Scratchpad. If Studio is connected to a server running with a DCEVM and you click Run in Debug Process , then Studio sends the Gosu code to the server. The PolicyCenter server uses the standard null-safe behavior for the period operator.

Run the Gosu scratchpad

Before you begin

To execute queries against the database in Studio or the Gosu scratchpad, you must first connect to a running application server.

About this task

The result of a query is always a read-only query object. To work with this read-only object, you must add it to a transaction bundle.

You can test the following in the Gosu scratchpad:

Code

Description

Expression

Returns the result of evaluating the (single-line) expression.

Program

Displays the output of the program, including calls to print and exception stack traces.

  • To run the Gosu scratchpad, click Tools > Gosu Scratchpad .

Executing code in the Gosu scratchpad

Procedure

Type your code, and then click Run .

Accessing application data in the Gosu scratchpad

You can always use the Gosu scratchpad to test generic Gosu code. If the scratchpad code needs to access application data, then the PolicyCenter server must be running in debug mode. For example, the following code accesses group and user entities, and therefore requires access to the application server:

var group : Group = Group(2)
for (var member in group.Members) {
  print(member.User.Contact.LastName)
}

To access application data in the Gosu scratchpad, run the PolicyCenter server in debug mode, and then instruct the scratchpad to run your code in that process. The DCEVM must be installed on the server. For information on running the PolicyCenter server in debug mode, see Testing PolicyCenter with Guidewire Studio.

See also

Run scratchpad code in the application server debug process

Procedure

Type your code, and then click Run in Debug Process .