Teledyne LeCroy WaveExpert 100H Operators Manual User Manual
Page 292
Operator’s Manual
290
WE-OM-E Rev A
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