WR6K-OM-E Rev A
ISSUED: October 2003
285
Error Handling
Note that the construction OnError GoTo Label: is not allowed in VBS. In fact no GoTos or labels
are allowed. Therefore there is no way for you to provide handlers to deal with errors and
exceptions. You must be aware of all possibilities at all points in your program, and you must
either be certain that errors will not occur, or you must take action to ensure that they do not.
Examples:
Sqr
You cannot take the square root of a negative number.
Log
You cannot take the log of zero or of a negative number.
A / B
You cannot divide by zero.
Array
You cannot use an index outside the bounds of an array.
Size
Unscaled data cannot go outside the range -32768 to 32767.
If there is any possibility that any of these might occur, take steps to deal with this before it can
happen.
For example, you may write some kind of generator of pseudo-random statistical values. If these
belong to a distribution that in principle has an infinite range, or a finite range which is wider than
the signed 16-bits allowed, check each value. If a value falls outside the range, you could set it to
the maximum or generate another example.
You can, however, use one of the following:
On Error Resume Next
followed by some code that may make some attempt to deal with the problem, or at least to allow
execution to continue.
On Error GoTo 0
This cancels On Error Resume Next_
Speed of Execution
To maximize the speed of execution of a script, the most important thing you can do is to
minimize the number of operations that are performed inside loops. Anything done once only is
unlikely to be an important source of delay. Please note that VBS is much slower than the internal
computations of the instrument, so do everything you can to save time, unless time is irrelevant to
the application.
Using an array element takes longer than using a single variable. Here is an example:
For K = 1 to Total
If X (K) > X (K - 1) Then
Summary of Contents for 6000 SERIES
Page 65: ...WR6K OM E Rev A ISSUED October 2003 63 Proper Orientation of Drive ...
Page 131: ...WR6K OM E Rev A ISSUED October 2003 129 Example ...
Page 141: ...WR6K OM E Rev A ISSUED October 2003 139 ...
Page 236: ...Operator s Manual 234 ISSUED October 2003 WR6K OM E Rev A Example 6 ...
Page 261: ...WR6K OM E Rev A ISSUED October 2003 259 ...
Page 286: ...Operator s Manual 284 ISSUED October 2003 WR6K OM E Rev A ...
Page 304: ...Operator s Manual 302 ISSUED October 2003 WR6K OM E Rev A ...
Page 307: ...WR6K OM E Rev A ISSUED October 2003 305 Convolve two signals ...
Page 348: ...Operator s Manual 346 ISSUED October 2003 WR6K OM E Rev A ...
Page 402: ...Operator s Manual 400 ISSUED October 2003 WR6K OM E Rev A ...