Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dim Array error - expected integer constant

118 views
Skip to first unread message

gnrs

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
Why do I get this error?

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

gnrs

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
Ok this seems to work:

Dim arrDept()
Redim arrDept(nDept,1)

Just don't know why?

Charles Kerekes

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
"gnrs" <l...@ntlworld.com> wrote in message
news:#fx0vAxSAHA.195@cppssbbsa05...

> Ok this seems to work:
>
> Dim arrDept()

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

Tom Lavedas

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
gnrs wrote:
>
> Ok this seems to work:
>
> Dim arrDept()

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/

Al Dunbar

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to

"Charles Kerekes" <dont...@me.email> wrote in message
news:eGAEqIySAHA.180@cppssbbsa04...

> "gnrs" <l...@ntlworld.com> wrote in message
> news:#fx0vAxSAHA.195@cppssbbsa05...
> > Ok this seems to work:
> >
> > Dim arrDept()
>
> 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

Not "vector", but "scalar". In some languages (Fortran, anyway) "vector"
implies a one-dimensional array, and "matrix" implies a two-dimensional one.


/Al


Charles Kerekes

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to

> 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

Al Dunbar

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to

"Charles Kerekes" <dont...@me.email> wrote in message
news:uHmURvXTAHA.197@cppssbbsa04...

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


Charles Kerekes

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to

"Al Dunbar" <Al_D...@HoTMaiL.com> wrote in message
news:t10i3q4...@corp.supernews.com...

> "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,

You are correct, "scalar" is the answer. Thanks for clarifying.

Charlie


0 new messages