Dim in LotusScript: Common mistake
If you need to dimension two Integer variables i and j, then in some programming languages you can do it this way:
Don't do this in LotusScript, it won't work (well, it will, but not in a good way). Try the following code snippet yourself to see what Notes does here:
You will receive:

Notes doesn't assign a type to i (notice: NOT a bug, just different interpretation - who said you can't have misunderstandings speaking LotusScript, too ;-)). To do it correctly, you have to dimension the variables the old-fashioned way:
More lines of code, but safer (and actually more readable, too).
Dim i, j As Integer
Don't do this in LotusScript, it won't work (well, it will, but not in a good way). Try the following code snippet yourself to see what Notes does here:
Dim i, j As Integer
Msgbox "Type of i: " & Typename(i) & Chr$(13) & "Type of j: " & Typename(j)
Msgbox "Type of i: " & Typename(i) & Chr$(13) & "Type of j: " & Typename(j)
You will receive:

Notes doesn't assign a type to i (notice: NOT a bug, just different interpretation - who said you can't have misunderstandings speaking LotusScript, too ;-)). To do it correctly, you have to dimension the variables the old-fashioned way:
Dim i As Integer
Dim j As Integer
Dim j As Integer
More lines of code, but safer (and actually more readable, too).




Last seen at...
2 Comments:
I think you can do it: Dim i as Integer, j As Integer
Hi Vitor,
thanks for your comment. This is correct, that is one way to do it. What I have seen, though, is that the first "as Integer" gets forgotten often.
Post a Comment
Thank you for your comment. It will be published shortly. Keep having a great day!
<< Home