Can someone look at the below script and tell me why it\'s throwing this error subscript out of range error in vbscript ..In the text file there are two entries it writes to the
If your file contains trailing blank lines, applying Split() may return arrays with less than 2 elements. In that case token(1)
should throw a 'subscript out of range' error.
You should always check, if Split() workes as expected:
tokens = Split(Trim(re.Replace(f.ReadLine, " ")))
If 1 = UBound(tokens) Then
extension = Split(tokens(0),".")
If 1 = UBound(extension) Then
strInputPath1 = "..." & tokens(1) & "..."
Else
... parse error ...
End If
Else
... parse error or just trailing blank lines? ...
End If