266
SDA-OM-E Rev H
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
Y = Cos (X (K) ) * Sin (X (K) ) * Sqr (X (K) )
End If
Next
To do the same thing we could also write this, using the index only once:
OldXK = X (0)
For K = 1 To Total
XK = X (K)
If XK > OldXK Then
Содержание SDA
Страница 1: ...SERIAL DATA ANALYZER OPERATOR S MANUAL December 2007 ...
Страница 148: ...Standard Horizontal Parameter Help Markers Standard Vertical Parameter Help Markers 148 SDA OM E Rev H ...
Страница 223: ...SDA Operator s Manual Example 6 SDA OM E Rev H 223 ...
Страница 225: ...SDA Operator s Manual SDA OM E Rev H 225 ...
Страница 232: ...In this figure the panel has been pasted onto the Excel sheet for comparison 232 SDA OM E Rev H ...
Страница 243: ...SDA Operator s Manual This example used the CORREL Array1 Array2 function of Excel as depicted below SDA OM E Rev H 243 ...
Страница 246: ...246 SDA OM E Rev H ...
Страница 247: ...SDA Operator s Manual Excel Example 5 Using a Surface Plot SDA OM E Rev H 247 ...
Страница 279: ...SDA Operator s Manual Convolving two signals SDA OM E Rev H 279 ...
Страница 310: ...The jitter wizard is accessed from the Analysis drop down menu 310 SDA OM E Rev H ...
Страница 327: ...SDA Operator s Manual SDA OM E Rev H 327 ...
Страница 328: ...328 SDA OM E Rev H ...
Страница 394: ...394 SDA OM E Rev H ...
Страница 395: ...SDA Operator s Manual SDA OM E Rev H 395 ...