Keeping a trace on things
When writing scripts, especially when getting into more advanced structures such as For
or For Each
loops, it can be important to see what is going on in the script.
The Trace
statement allows us to write information to the Script Execution Dialog, which gives immediate feedback on what is going on, so that we can quickly diagnose issues.
Getting ready
Load the following script:
For i = -10 to 10 Let vTemp = $(i) / If($(i)=-10, 1, Peek('X')); Data: Load $(i) As X, Round($(vTemp), 0.001) As Y AutoGenerate(1); Next
How to do it...
These steps show you how to use Trace
to write to the Script Execution Dialog:
Add a table box with fields
X
andY
.The script loaded with errors. We have had errors and we are not getting the correct result. Add the following line of script after the
Let
statement:Trace On row $(i), the result is $(vTemp);
Reload the script:
Note that the first failure occurs on row 1 and all other rows after that fail.
Change the script to...