Adobe 27510753 Scripting Guide - Page 50

Testing and troubleshooting, AppleScript debugging

Page 50 highlights

42 Getting Started with InDesign Scripting Adobe InDesign CS2 Scripting Guide Testing and troubleshooting Scripting environments provide tools for monitoring the progress of your script as it runs. This makes it easier to find problems that your script might encounter or cause. AppleScript debugging The Apple Script Editor application doesn't have extensive debugging tools, but it does have the AppleScript Event Log Window. To watch your script send commands to and receive information from InDesign: 1. Choose Controls > Open Event Log. The Script Editor displays the Event Log window. 2. Turn on the Show Events and Show Events Results options. 3. Run your script. As the script executes, you'll see the commands sent to InDesign, and the InDesign responses. In addition, the Result window (choose Controls > Show Result) displays the value returned from the most recent script statement. Third-party AppleScript editors, such as Script Debugger (from Late Night Software: www.latenightsw.com) offer more debugging features than the Apple Script Editor. If you will be writing more than a few simple scripts, we recommend that you acquire a script editor with better script debugging capabilities. VBScript debugging You can debug your VBScript using a Visual Basic debugger. In Visual Basic, you can stop your script at any point and step through the script one line at a time. You can also observe the values of variables defined in your script using the Watch and Locals windows-two valuable tool for debugging your scripts. To view a variable in the Watch window: 1. Select the variable and choose Debug > Quick Watch. Visual Basic displays the Quick Watch dialog box. 2. Click Add. Visual Basic displays the Watch window. 3. To stop your script at a particular line (so that you can look at the Watch window), select the line and choose Debug > Toggle Breakpoint. When you run the script, Visual Basic stops at the breakpoint you set, and you can look at the values in your variables (if you've hidden the Watch window, you can display it again by choosing View > Watch Window). 4. Choose one of the following continuation options: l To execute the next line of your script, choose Debug > Step Into (or press F8 in Visual Basic 6 or F11 in Visual Basic.NET). l To continue normal execution of the script, choose Run > Start (or press F5) in Visual Basic 6 or Debug > Start (or press F5) in Visual Basic.NET. JavaScript debugging JavaScript debugging is described in Chapter 4, "Using ExtendScript Tools and Features."

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

42
Getting Started with InDesign Scripting
Adobe InDesign CS2 Scripting Guide
Testing and troubleshooting
Scripting environments provide tools for monitoring the progress of your script as it runs. This makes it easier
to find problems that your script might encounter or cause.
AppleScript debugging
The Apple Script Editor application doesn’t have extensive debugging tools, but it does have the AppleScript
Event Log Window. To watch your script send commands to and receive information from InDesign:
1.
Choose Controls > Open Event Log. The Script Editor displays the Event Log window.
2.
Turn on the Show Events and Show Events Results options.
3. Run your script.
As the script executes, you’ll see the commands sent to InDesign, and the InDesign responses. In addition,
the Result window (choose Controls > Show Result) displays the value returned from the most recent script
statement.
Third-party AppleScript editors, such as Script Debugger (from Late Night Software: www.latenightsw.com)
offer more debugging features than the Apple Script Editor. If you will be writing more than a few simple
scripts, we recommend that you acquire a script editor with better script debugging capabilities.
VBScript debugging
You can debug your VBScript using a Visual Basic debugger. In Visual Basic, you can stop your script at any
point and step through the script one line at a time. You can also observe the values of variables defined in
your script using the Watch and Locals windows—two valuable tool for debugging your scripts.
To view a variable in the Watch window:
1.
Select the variable and choose Debug > Quick Watch. Visual Basic displays the Quick Watch dialog box.
2.
Click Add. Visual Basic displays the Watch window.
3.
To stop your script at a particular line (so that you can look at the Watch window), select the line and
choose Debug > Toggle Breakpoint. When you run the script, Visual Basic stops at the breakpoint you set,
and you can look at the values in your variables (if you’ve hidden the Watch window, you can display it
again by choosing View > Watch Window).
4.
Choose one of the following continuation options:
To execute the next line of your script, choose Debug > Step Into (or press F8 in Visual Basic 6 or F11 in
Visual Basic.NET).
To continue normal execution of the script, choose Run > Start (or press F5) in Visual Basic 6 or Debug >
Start (or press F5) in Visual Basic.NET.
JavaScript debugging
JavaScript debugging is described in Chapter 4, “Using ExtendScript Tools and Features.”
l
l