Date tip published: | 09/07/2004 |
Description: | The "Option Declare" option prevents implicit declarations in a script. When you set this option, you must explicitly declare all variables, including variant variables. Using this option provides a built-in spell checker for your script because any misspelled variable names will cause a compile-time error that you can easily locate and correct. For this reason, you should always use this feature. |
To learn more about Using the Option Declare statement in LotusScript code use the following links:
Beginner LotusScript for Notes Domino 6
Intermediate LotusScript for Notes Domino 6
Advanced LotusScript for Notes Domino 6
Option Declare: LotusScript's Compile-Time Spell Checker
The "Option Declare" option prevents implicit declarations in a script. When you set this option, you must explicitly declare all variables, including variant variables. Using this option provides a built-in spell checker for your script because any misspelled variable names will cause a compile-time error that you can easily locate and correct. For this reason, you should always use this feature.
Example: Innocent Spelling Errors in a Script
Consider the following code and note the spelling error in the multiplication expression in Line 6. When the code in this example executes, Notes implicitly declares a new nQantity variable and initializes it to zero. The result of this calculation is then zero when it should be 1295. That's quite a difference!

1. | 
Dim vntResult As Variant |

2. | 
Dim nQuantity As Integer |

3. | 
Dim dPrice As Double |

4. | 
nQuantity = 100 |

5. | 
dPrice = 12.95 |

6. | 
vntResult = nQantity * dPrice |

7. | 
Messagebox vntResult, MB_OK, "Total Cost" |
Finding this type of error in a simple script may take a few minutes. In a more complex script, finding a spelling error could take hours!
With the Option Declare statement set for this script, Notes raises a compile-time error when you attempt to save the script because no explicit declaration exists for the misspelled variable. In this case, the LotusScript Editor displays the offending line of code in red making it very easy to locate and fix.
Procedure: Setting Option Declare
Follow these steps to enable the Option Declare built-in spell checker:
- In Domino Designer, expand the desired design object in the Objects list in the Programmer's Pane to display its events.
- Select the (Options) event and enter the Option Declare statement in the script area.
- Save your changes.
|