global DIMs
Jan 15, 2009 17:15:24 GMT -5
Post by veneff on Jan 15, 2009 17:15:24 GMT -5
I am trying to understand what limitation there may be with the DIM statement.
Any DIMed variables are automatically global.
But it seems as if you can't declare a DIMed variable in a SUBroutine. It seems to act as if it is local to that routine, ie:
CALL MakeArray
FOR I = 1 to 20
Array(I) = I
NEXT I
END
SUB MakeArray
DIM Array(20)
END SUB
causes error:
Runtime Error in program 'untitled': Array(I) = I
Message not understood: #value:
And apparently you can not reDIM a variable in a subroutine and expect to access the increased size of it in the main portion of the program, ie:
DIM Array(10)
CALL MakeArray
FOR I = 1 to 20
Array(I) = I
NEXT I
END
SUB MakeArray
DIM Array(20)
END SUB
causes error:
Runtime Error in program 'untitled': Array(I) = I
Index out of bounds: 11
Vance
Any DIMed variables are automatically global.
But it seems as if you can't declare a DIMed variable in a SUBroutine. It seems to act as if it is local to that routine, ie:
CALL MakeArray
FOR I = 1 to 20
Array(I) = I
NEXT I
END
SUB MakeArray
DIM Array(20)
END SUB
causes error:
Runtime Error in program 'untitled': Array(I) = I
Message not understood: #value:
And apparently you can not reDIM a variable in a subroutine and expect to access the increased size of it in the main portion of the program, ie:
DIM Array(10)
CALL MakeArray
FOR I = 1 to 20
Array(I) = I
NEXT I
END
SUB MakeArray
DIM Array(20)
END SUB
causes error:
Runtime Error in program 'untitled': Array(I) = I
Index out of bounds: 11
Vance