Hi!
First, I have to admit, I actually am a Java guy and regularly lose my temper with VBScript's inconsistancy. So I might have already created a blind spot. But I still dont get this:
I have a function that returns an array (pasted later), and for some reason when I call it and want to assign it to a variable it tells me "Object required". AND NOTHING else (what an excellently accurate error message).
the line that produces the error:
set indices=stringTokenize("1;3;4;6;7;10", ";")
(I tried a dim indices() and dim indices(6) and much more before calling this function).
The function itself works, when I debug it to the end the return value is the correct array, but as soon as it jumps out of the function and should assign the return value to "indices" it comes up with this superweird error message.
Maybe its necessary to see the method in order to help me, so here it is, but I think its pretty irrelevant.
Function stringTokenize(wholeString, delimiter)
dim pos, i, found, lastPos
redim allTokens(0)
pos=1
i=0
found=0
While pos>0
ReDim preserve allTokens(i)
lastPos=pos
pos=instr(lastPos, wholeString, delimiter)
if(pos>0) then
allTokens(i)=mid(wholeString, lastPos, pos-lastPos)
pos=pos+1
else
allTokens(i)=mid(wholeString, lastPos)
end if
found=found+1
i=i+1
Wend
stringTokenize=allTokens
End Function
----------------------------------------
So why do I get this "Object required" error? Which object is required? The Strings surely not...
THANK YOU VERY MUCH!!!
CC
First, I have to admit, I actually am a Java guy and regularly lose my temper with VBScript's inconsistancy. So I might have already created a blind spot. But I still dont get this:
I have a function that returns an array (pasted later), and for some reason when I call it and want to assign it to a variable it tells me "Object required". AND NOTHING else (what an excellently accurate error message).
the line that produces the error:
set indices=stringTokenize("1;3;4;6;7;10", ";")
(I tried a dim indices() and dim indices(6) and much more before calling this function).
The function itself works, when I debug it to the end the return value is the correct array, but as soon as it jumps out of the function and should assign the return value to "indices" it comes up with this superweird error message.
Maybe its necessary to see the method in order to help me, so here it is, but I think its pretty irrelevant.
Function stringTokenize(wholeString, delimiter)
dim pos, i, found, lastPos
redim allTokens(0)
pos=1
i=0
found=0
While pos>0
ReDim preserve allTokens(i)
lastPos=pos
pos=instr(lastPos, wholeString, delimiter)
if(pos>0) then
allTokens(i)=mid(wholeString, lastPos, pos-lastPos)
pos=pos+1
else
allTokens(i)=mid(wholeString, lastPos)
end if
found=found+1
i=i+1
Wend
stringTokenize=allTokens
End Function
----------------------------------------
So why do I get this "Object required" error? Which object is required? The Strings surely not...
THANK YOU VERY MUCH!!!
CC