Code:
Dim nDept
'count the number of departments
nDept = countLevel(0,0) 'returns 3
Dim arrDept(nDept, 1)
Error:
Expected integer constant
/Superstore/3d.asp, line 11, column 12
Dim arrDept(nDept, 1)
-----------^
Searching msdn.microsoft.com this is the only explanation I find:
http://support.microsoft.com/support/kb/articles/Q215/4/01.ASP
But it gives no solution.
Thanks
Lyndon
Dim arrDept()
Redim arrDept(nDept,1)
Just don't know why?
This works because you dimensioned arrDept as an array. In your previous
example, you left off (), which made arrDept a vector (I think that's the
correct term -- not an array).
Charlie
The Dim statement can only create static arrays, when specific
dimensions are given. Static arrays must be explicitly defines, i.e.
without a variable as one of the dimensions. ReDim creates a dynamic
array - the Dim Array() part isn't explicitly required, though the
documentation implies it.
Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/
Not "vector", but "scalar". In some languages (Fortran, anyway) "vector"
implies a one-dimensional array, and "matrix" implies a two-dimensional one.
/Al
Al,
I thought that Perl used "vector" to mean any non-array variable. Is your
above statement applicable to Perl as well? Most likely I'm just not
remembering correctly.
Charlie
Not having any experience with Perl, I will have to claim ignorance
regarding how words are to be understood in a perl context (easy enough for
me :-).
If the context of the original post (which I have completely forgotten), was
in Perl, then the Perl meaning of the word should imply. If, however, it was
VBScript, then VBScript usage should apply. I can't find any refs to the
word "vector" in the vbscript docs, so the meaning of the term should be
deduced from common usage. Since common usage seems to depend significantly
on whatever unrelated context one is familiar with (perl, fortran), then it
would be best to keep the language direct and appropriate to the context. If
the context was VBScript, consider this quote from the docs:
"Variables and Array Variables
Much of the time, you just want to assign a single value to a variable
you've declared. A variable containing a single value is a scalar variable.
Other times, it's convenient to assign more than one related value to a
single variable. Then you can create a variable that can contain a series of
values. This is called an array variable. Array variables and scalar
variables are declared in the same way, except that the declaration of an
array variable uses parentheses ( ) following the variable name."
So, according to the (vbscript) docs, does [DIM Salary] define a scalar or a
vector?
/Al
Al,
You are correct, "scalar" is the answer. Thanks for clarifying.
Charlie