Dim bug

Archives Forums/Blitz3D Bug Reports/Dim bug

Fernhout(Posted 2007) [#1]
I do not know if this is a real bug but i have the following problem discovered:

I did make a separate program containing a function. A the start of that file i dim a variable

Dim Colors$(25)

At the start of the main program is include the file.
untile so far so good.

Then later in the main program i did dim the variable again but now i did use it to be a integer array

Dim Colors(3)

during compiling i do not get any warnings or stoping of the compiling of the program.

But because of this i got a error during running the program. Index ouf of range. As soon as the function is called.

I know that during compiling the use of dubble variables in differend settings (e.g int and Str) the compiling stops and point out that the variables are a mismatch.

So why do i get the error using normal variables and not when i use array's.

H&K(Posted 2007) [#2]
Well was the index out of range or not?

If you went Colors(4) then it is.
Are you not in fact redifineing colors(255) to be only 4 long?

Fernhout(Posted 2007) [#3]
Yes it did.

I do know now that the problem is not in the compiler but by myself. Once a variable get his type, you do not have to give the type definition again. So in the program that variable is automatic that kind of type.

You wil get an error if you try to change the type of a variable.
E.g. Color$ to a Color#
The compiler wil give than an variable type missmatch.

But because i did not use the type marker the compile take the type definition i gave it in the first place.

So i realy redim the array by mistake.

I have the problem already solved. But thanks for the reply.