Skip to main content

Bug when using arrays

I found this interesting problem using arrays and it only seems to happen in certain circumstances.

Here is some example code:

Dim aArray() As String

Sub Main
 
End Sub

Function updateFunctionNames(ByVal fileToRead As String) As String
      Dim oldFunctionsName() As String 'array to hold the old function names
      Dim newFunctionsName() As String 'array to hold the revised function names
      ReDim oldFunctionsName(0)

End Function

If you run the code as is what it will do is remove the ReDim oldFunctionsName(0) and change it to Dim oldFunctionsName(0).  It seems that it you remove the comment after this it will not make the change.  The problem looks like that even though there is a comment the IDEAScript editor sees the word function and thinks it is the start of a new function so the array should not be redefined.  It also seems to work if you remove the global array variable.  I have told IDEA support of this problem.  So if you come across a script in which the editor is changing ReDims to Dims then this could be the problem.