views:

3336

answers:

1

I have some VBScript code where a function returns an array.

function PreProcessFile (sFile)

    dim deData(3)

    ''populate deData with strings

    PreProcessFile = deData

End function

The code calling this function errs with a type mismatch. Any thoughts?

'' VBScript source code
Dim m_deData(3)
set m_deData = PreProcessFile("someFile.txt")
+5  A: 

Don't explicitly dim the size of the array outside the function and don't use set:

'' VBScript source code
Dim m_deData
m_deData = PreProcessFile("someFile.txt")
EBGreen
Thanks... I thought I was done with VBScript years ago but it found its way back to me...
Austin Salonen
If it is possible, you may look at moving to Powershell instead.
EBGreen
Powershell... arrghh nooo!! What were they thinking!!. Python may be an alternative or even JScript but frankly Powershell is a disaster. It goes way over the average administrators head and developers ought to have something better to do like writing software.
AnthonyWJones
Ehh...well it works for me. :)
EBGreen