https://bugs.winehq.org/show_bug.cgi?id=53767
Bug ID: 53767 Summary: vbscript fails to handle ReDim when variable is not yet created Product: Wine Version: 7.16 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: vbscript Assignee: wine-bugs@winehq.org Reporter: jsm174@gmail.com Distribution: ---
While working on leveraging the vbscript engine of Wine for a macos/linux port of Visual Pinball, I finally have the example table working and am starting to work through the runtime errors.
Since the table scripts are often copies of copies of copied code, sometimes bad practices make their way in.
Take the following code:
Const tnob = 5 ' total number of balls ReDim rolling(tnob)
This works in real vbscript, but fails here.
As a work around, I've updated the script to:
Const tnob = 5 ' total number of balls Dim rolling() ReDim rolling(tnob)
According to the rules I've found:
It's possible to create a new dynamic array within a procedure using the ReDim statement if the array to which it refers doesn't already exist at either module or level. Typically, this results from an error of omission; the programmer forgets to explicitly define the array using Dim, Public, or Private. Since this method of creating an array can cause conflicts if a variable or array of the same name is subsequently defined explicitly, ReDim should be used only to redimension an existing array, not to define a new one.