Command line runner: Debug options
When you use the mrScript Command Line Runner with the /x option, the following commands are available:
Run commands
S
Step through the code.
X
Execute the code.
Information commands
I
Display debug information.
L[<n>]
Display +/- <n> lines of code from the current position.
C
Display the script method call stack.
V[<variable>]
Display the value of the specified variable. If you do not specify a variable name, this displays the value of all of the local variables.
E
Display the contents of the Err object.
Breakpoint commands
B <n>
Toggle the breakpoint at line <n>.
BC
Clear all of the breakpoints.
BL
List all of the breakpoints.
Other commands
?[<statement>]
Evaluate the specified expression. This command can also be used to inspect the values of properties of objects.
![<statement>]
Execute the specified statement. This command is new in Data Model 2.8.
Q
Exit the debugging session.
H
Display a summary of the command syntax.
Example of using the debug options
This example shows you how to use the debug options to step through code, use the ? command to inspect the values of object properties, and use the ! command to change the value of an object property by executing an assignment statement.
1 Run the following code using the /x option:
Dim MDM, MyField
Set MDM = CreateObject("MDM.Document")
MDM.Open("museum.mdd")
MyField = MDM.Fields[0]
mrScript Command Line Runner displays the following:
Line:3, Opcode:0, Opcodes-Executed:0
1 Dim MDM, MyField
2
3->Set MDM = CreateObject("MDM.Document")
4 MDM.Open("museum.mdd")
5
6 MyField = MDM.Fields[0]
-
This indicates that mrScript Command Line Runner has executed the code on the first line and has stopped at the next line of code (which is actually line 3).
2 Type: s
mrScript Command Line Runner executes this line and stops on the next line (line 4):
Line:4, Opcode:3, Opcodes-Executed:3
1 Dim MDM, MyField
2
3 Set MDM = CreateObject("MDM.Document")
4->MDM.Open("museum.mdd")
5
6 MyField = MDM.Fields[0]
-
3 Type s again.
mrScript Command Line Runner executes line 4, which opens the Museum sample .mdd file, and stops on line 6:
Line:6, Opcode:6, Opcodes-Executed:6
3 Set MDM = CreateObject("MDM.Document")
4 MDM.Open("museum.mdd")
5
6->MyField = MDM.Fields[0]
-
4 Next, use the ? command to inspect the name of one of the objects in the MDM.Fields collection. To do this, type:
?MDM.Fields[10].Name
mrScript Command Line Runner then returns the value of the Name property:
-?MDM.Fields[10].Name
"museums"
-
5 Now use the ? command to display the object's label. Type:
?MDM.Fields["museums"].Label
This time mrScript Command Line Runner returns the value of the Label property:
-?MDM.Fields["museums"].Label
"Museums and galleries visited or plans to visit"
-
6 Use the ! command to change the value of the label. For example, type:
-!MDM.Fields["museums"].Label = "Museums, galleries, and exhibitions visited"
-
7 Use the ? command again to display the updated label:
-?MDM.Fields["museums"].Label
"Museums, galleries, and exhibitions visited"
-
8 Type x to execute the remainder of the code.
This example is deliberately simplistic. In practice you are unlikely to want to use the debugging features on such simple code. However, the debugging features are useful when you work on more complicated scripts and get unexpected results. Using the debugging features to step through the code, set up breakpoints, examine the contents of variables and object properties at critical stages in your script, will help you track down any logical errors in your code.
See