The Script Console

Whenever you preview a page or a publication in Opus, a Script Console window may appear on top of the preview. The Script Console will appear for the following reasons:

      1. Syntax errors – if a script on the current page contains syntax errors, the console will appear showing an Errors tab with a brief description of the error.

      2. Debug statements – if you use the Debug.trace or Debug.tracePane functions in one of your scripts, the console will appear showing the contents of a variable.

The Script Console

  1. The Script Console contains two tabs at the bottom of the window, these are the Defaults tab and the Errors tab – these are described below.

  2. The Script Console window is a useful tool when writing Scripts because it acts as a warning system that there are syntax errors in your code, which means your publication does not work as you intended it to do. Error messages are shown in the Error tab of the console.

  3. If an error appears in the Error tab, then the Script Console will remain on the page when you exit the preview screen. Double-click on any error message in the Error tab and the corresponding script will be opened and the Script Editor pane will go to the line that contains the error.

Note:
For some types of errors, this may not be possible.

  1. The Script Console is also useful as a debugging tool for developers to check their code for possible errors. For example, if you are unsure what the current value of a variable is, you can use a Debug.trace function to show the value of a variable while the publication is running. The value will be displayed in the Default tab of the console.

Note:
If you use the Debug.tracePane function, you can create your own tab in the console in which the data is entered. Debug.trace can also be used to display material in the Script Console in Flash – you need to set the option to View the Script Console in the Publish Settings.

View / Hide the Script Console

  1. Select Script Console from the View menu at the top of the Opus Editor- the Script Console will open as a separate window and displays the results of the last page previewed (if any).

  2. By default, the Script Console does not appear in the Opus Editor but only when you preview your publication and a script either contains an error or you have used a Debug.trace function.

  3. To hide the console when you are in the Opus Editor, simply select the Script Console option again from the View menu or click the close button in the top right-hand corner of the console window.

Recommended Script Console options

  1. There are a variety of viewing options that you can set for the Script Console. By default, these are set to the recommended settings; however, you can change them if required.

  2. To reset the options, select Options from the Tools menu at the top of the Opus Editor – this will open the Options dialog. Select the Script folder in the Options Organiser on the left-hand side of the Options dialog – the Script options will appear on the right-hand side of the dialog.

  3. The Script Console panel in the Script folder shows the current settings for the Script Console window. Below are the recommended settings for the Script Console panel.

  4. Clear the Show console when preview starts option in the Script Console panel. You only want the console to appear if there are errors or you have entered debug statements.

  5. Select Show console when any output is written option in the Script Console panel. The Script Console will appear when you have entered debug statements in an OpusScript.

  6. Select Show console when "Errors" pane is written to option in the Script Console panel. The Script Console will appear when errors occur in your OpusScript.

  7. Clear Hide the console when the preview finishes option in the Script Console panel. When you exit the preview of your page/publication the Script Console will remain open; it is most likely you will want to check your errors against the code you have written in the OpusScript.

  8. Select Clear the console when preview starts option in the Script Console panel. Previous entries in the Error tab and Default tab will be cleared, only new errors or debug statements will appear in the Script Console.

  9. Select Switch to output pane option in the Script Console panel. This ensures that the console pane that has most recently been written to will be displayed.

  10. Click the OK button at the bottom of the Options dialog to save your changes.

Published applications and the Script Console

  1. The Script Console window will only appear as you are developing a publication. The Script Console will never appear in a Published version of your publication.

  2. The Script Console will not appear in a published version if any of your scripts contain the debug statement Debug.trace(). Debug statements are only displayed in the Script Console when the publication is being developed, the same debug statements are ignored when the application is published.

  3. The Script Console will not appear if the published version contains syntax errors in any Script Action or Script Object within the publication. Before you publish your application, preview the entire publication and ensure you have corrected any syntax errors that appear in the Script Console window.

Note:
In the main Opus Help file there is a topic on debugging OpusScript, select Contents & Index from the Help menu at the top of the Opus Editor to open the main Opus Help file. Search for the word debugging in the Index tab to find the topic.

Related Topics:

Where do I write my OpusScript?