Script Editor and Debugger
The Script Editor is where you write, run, and debug the scripts of Scripting DeltaWalker Classic. Each script opens in its own editor tab. The script’s output appears in the Console, and when you set a breakpoint, the editor can pause the script and show you the values of its variables.
The Script Editor, the Script menu, and the commands described here are part of DeltaWalker Classic Pro and Oro, and of the trial. DeltaWalker Classic Standard runs the ready-made workflows but doesn’t offer to edit or run scripts of your own. DeltaWalker Classic Free and the Mac App Store edition have no scripting.
Opening a script
- File > Script > New opens an empty, untitled script.
- File > Script > Open… asks for a file. The chooser lists DeltaWalker Script Files (*.js) by default; choose All Files (*.*) to see every file.
- File > Script also lists the scripts you opened recently, below Open…. Choose one to bring it back.
- The Workflows button on the main toolbar has New Script… and Open Script… in its menu.
- In the Workflow Gallery, Open Source opens a workflow’s script, and Debug opens it and runs it.
- On the command line,
-script=<path to script>opens the script and runs it as soon as DeltaWalker Classic has started. See Command Line.
Opening a script also shows the Console.
Running a script
Run the script in the active editor in any of these ways:
- Press Cmd+Shift+R. The shortcut works only while the editor has the keyboard focus. Click inside the script first if it does nothing.
- Click the round run button at the top right of the editor. Its tooltip reads Execute Script.
- Choose File > Script > Run.
If the script came from a file and has unsaved changes, DeltaWalker Classic saves them first, so what runs is what you see. A new, untitled script is not saved; it runs as it is. The Run command is not available while a script is running or paused.
Output and errors
A script’s output goes to the Console. Choose Window > Show Console to open it, or Window > Hide Console to close it again.
console.log(...)writes ordinary text.console.error(...)writes in red. When a script fails, for example because of a mistyped method name or a folder that doesn’t exist, the error message appears in the Console as well.- The Console is cleared each time you run a script. Copy anything you want to keep before you run again.
- While you debug, DeltaWalker Classic also writes its own lines to the Console in green. See When the script pauses.
Saving
Choose File > Save (Cmd+S) or File > Save As… while the editor has the focus. The Save As dialog offers the same DeltaWalker Script Files (*.js) and All Files (*.*) filters as the Open dialog. Right-clicking in the editor also gives you Save As…, together with Undo, Redo, Cut, Copy, Paste, and Select All.
Breakpoints
A breakpoint makes a script pause just before it runs a line. To set one, click in the ruler at the left edge of the editor next to the line. A marker appears in the ruler. Click the marker again to remove the breakpoint.
Breakpoints belong to the script and are kept for as long as DeltaWalker Classic is running, even if you close the editor tab. They are not saved with the script and are gone the next time you start DeltaWalker Classic.
You can also write the statement debugger; on a line of its own. The script pauses there as it would at a breakpoint. Use a breakpoint for something you set and remove while you work, and debugger; for a stop that should stay in the script.
When the script pauses
When the script reaches a breakpoint or a debugger statement, it stops, and the editor shows where:
- The current line is highlighted in yellow, and the editor scrolls to it.
- The status line at the bottom of the window reads Paused at line N in followed by the name of the script.
- The Variables panel appears below the editor. Its heading reads Variables — paused at line N. It is a table with a Name column and a Value column that lists the script’s variables at that point. The values are text previews taken at the moment of the pause. The panel disappears when the script continues.
- The Console gets matching green lines: one starting with
[debug]that says where the script paused and how many variables it has, followed by one line for each variable in the formname = value.
Nothing else in DeltaWalker Classic stops while a script is paused. You can still switch to other windows, but the script does not run, and the Run command stays unavailable until it ends.
Continuing a paused script
Resume, Step Over, and Stop are part of the Script Editor’s own toolbar. In the default window layout of this release that toolbar is not shown, and the commands have no menu item and no keyboard shortcut. So there is, at present, no visible way to resume a paused script, or to step to the next statement, or to stop it.
What does happen: a paused script continues by itself after 10 minutes, and runs on to the end or to the next breakpoint. Until then it waits. Plan for this when you debug: set breakpoints only where a pause of that length is acceptable, and use console.log(...) when you only want to see a value.