Dimensioning of single dimension arrays within a class 
Author Message
 Dimensioning of single dimension arrays within a class

I have written a specialized linked list class in which I singly dimension
variables that I add to a table. My class has a PutEntry( PathID, tme, dur,
state) method and a Sub Class_initialize. I Have arrays of fixed size
declared in class like
private PrevPathID(100) and I set members of the array with satements like
PrevPathID(i) = PathID or PrevPathID(i) = 0 in the respective routines
above. (i is a
loop index or is defined as a variable.)
    I am getting type mismatch compilation messages.
Is what I am doing legal?
The version of Wscript/Cscript is5.1.0.4615.
     I thank you, in advance, for your answer.
    R. Cherry


Sun, 26 Jan 2003 03:00:00 GMT  
 Dimensioning of single dimension arrays within a class
There is an undocumented limitation in the current implementation of VBScript classes regarding
class level variables, whether defined using Dim, Public, Private, or Const.  You may only define
only simple variant variables.

Defining arrays [such as Private foo() or foo(100)] or constants [such as Const bar = "bar"] is not
supported.  However, using this kind of syntax does NOT generate any compile time errors, only
runtime errors when the variables are later referenced.

The only known workaround is to define simple variant variables with the appropriate scope at the
class level and use Class_Initialize() to ReDim foo(-1) or ReDim foo(100) and also to assign initial
values to variables that you intended to be constants.

--
Michael Harris
MVP Scripting

I have written a specialized linked list class in which I singly dimension
variables that I add to a table. My class has a PutEntry( PathID, tme, dur,
state) method and a Sub Class_initialize. I Have arrays of fixed size
declared in class like
private PrevPathID(100) and I set members of the array with satements like
PrevPathID(i) = PathID or PrevPathID(i) = 0 in the respective routines
above. (i is a
loop index or is defined as a variable.)
    I am getting type mismatch compilation messages.
Is what I am doing legal?
The version of Wscript/Cscript is5.1.0.4615.
     I thank you, in advance, for your answer.
    R. Cherry



Sun, 26 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. single dimension array into multiple dimension array

2. Treeview and single Dimension Array

3. Convert multi-dimension vbscript array to javascript array

4. Dimensioning a Picture Control to the dimensions of a variable dimension video With MMControl.

5. Dimensioning within a If End If

6. set array with 2 dimensions into combobox

7. How to refer to just *one* of the dimension of a multi-dimensional array in VBA

8. Sorting 2 Dimension Array

9. Sorting 2 dimension array

10. Multi-Dimension Arrays - how to pass to routines?

11. HLP: Sort Multi-Dimension Array

12. Print contents of 2 dimension array?

 

 
Powered by phpBB® Forum Software