Hi,
I make program using VBscrip in PADS.
But I encounter difficulty.
The problem is split function.
Whenever I use split function at my script,
the script has problem.
"Expecting an already dimensioned array"
I don't know why the syntax has problem.
For example, I wrote simple script.
Sub Main
Dim jArray() As String
Dim lTemp As String
lTemp = "abc,def,jgj"
jArray = Split(lTemp, ",") ' Error
For i = 0 To UBound(jArray)
MsgBox jArray(i)
Next
End Sub
Reference manual about "Split" function ================================
Syntax : Split(Str, [Sep], [Max])
Description : Return a string array containing substrings from the original string.
Parameter Description ----------------
Str : Extract substrings from this string value.
Sep : Look for this string value to separate the substrings. (Default: " ")
Max : Create at most this many substrings. (Default -1, which means create as many as are found.)
I have found different scripting environments sometimes have subtle differences in expected vb script syntax. This is not the fault of any scripting environment, it just reflects that different scripting engines are just slightly different from each other.
For example, I copied and pasted your supplied script into Microsoft Visual Studio 6.0, and it worked right off the bat with no changes.
I then saved the same script to an ASCII file locally, and called the script from Expedition using the Keyin Command toolbar. I ended up getting errors of different sorts until I changed the script to the following, which then worked as expected:
Dim jArray
Dim lTemp
dim i
lTemp = "abc,def,jgj"
jArray = Split(lTemp, ",")
For i = 0 To UBound(jArray)
MsgBox jArray(i)
Next
Sometimes you just need to play with the code a little bit to see what works for that scripting engine. Sometimes code from one environment requires a bit of tweaking in order to run correctly in another environment.
I hope this helps, good luck.
Thanks
Chris