Help with arrays in VBS
Why can't I resize an array more than one time?
from
WinCustomize Forums
I have windows script host version 5.6.8820
I have DesktopX 3.1 full (not pro not public ... cant remember how u spell it hehe)
The thing i need to do is make an Array to contain some data but the array must be accessable from and function or sub within the objects code.
so here's a short script wich causes the folowing error:
Subscript out of range
Line: 17
Code:
(not available)
Dim x()
Dim y
'Called when the script is executed
Sub Object_OnScriptEnter
y = -1
y = y + 1
End Sub
Function Rescale(Enabled)
If Enabled = True Then
ReDim Preserve x(y, 5)
ReDim Preserve x(y, 5)
x(0, 0) = 1
y = y + 1
ReDim Preserve x(y, 5)
y = y + 1
ReDim Preserve x(y, 5)
Do While y < 10
y = y + 1
ReDim Preserve x(y, 5)
Loop
End If
MsgBox "Done"
End Function
Sub Object_OnLButtonUp(x, y, Dragged)
If Dragged = False Then
Rescale True
End If
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
End Sub
It is werry important for my widget to use arrays and there is no other way i can do the thing i want.
This is a bit trivial code but it is enough to produce an error. The documentation of windows script host doesn't say anything about this problem.
Do I need the latest version?
I have WinXP SP1 and SP2 by the way.
Thank you for help in advance!
I have DesktopX 3.1 full (not pro not public ... cant remember how u spell it hehe)
The thing i need to do is make an Array to contain some data but the array must be accessable from and function or sub within the objects code.
so here's a short script wich causes the folowing error:
Subscript out of range
Line: 17
Code:
(not available)
Dim x()
Dim y
'Called when the script is executed
Sub Object_OnScriptEnter
y = -1
y = y + 1
End Sub
Function Rescale(Enabled)
If Enabled = True Then
ReDim Preserve x(y, 5)
ReDim Preserve x(y, 5)
x(0, 0) = 1
y = y + 1
ReDim Preserve x(y, 5)
y = y + 1
ReDim Preserve x(y, 5)
Do While y < 10
y = y + 1
ReDim Preserve x(y, 5)
Loop
End If
MsgBox "Done"
End Function
Sub Object_OnLButtonUp(x, y, Dragged)
If Dragged = False Then
Rescale True
End If
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
End Sub
It is werry important for my widget to use arrays and there is no other way i can do the thing i want.
This is a bit trivial code but it is enough to produce an error. The documentation of windows script host doesn't say anything about this problem.
Do I need the latest version?
I have WinXP SP1 and SP2 by the way.
Thank you for help in advance!