Posts: 303
Threads: 10
Joined: Apr 2022
Reputation:
44
It's functionally the same, where is that quote from?
They might be talking about using `REDIM` to resize existing arrays, in which case yes it is kinda expensive for larger arrays, mostly if you use `_PRESERVE`. If you're just replacing all your DIM statements with REDIM though then that wouldn't apply since you wouldn't have any resizes happening after the array is first declared.
Posts: 3,932
Threads: 175
Joined: Apr 2022
Reputation:
215
Yes thats probably it, I am thinking flat out substitution redim where there was dim, he maybe thinking _preserve operation.
Thanks for your reply. Oh quote is from another forum, an O2 fan.
b = b + ...
Posts: 2,695
Threads: 326
Joined: Apr 2022
Reputation:
217
May also be an issue with having to reset array values to 0.
TYPE foo
x AS STRING
y AS LONG
END TYPE
REDIM whatever(1000) AS foo
I seem to remember that the above doesn't always initialize arrays to 0, so you may need to do so manually for that, leading to extra run time and such.
Posts: 381
Threads: 56
Joined: Apr 2022
Reputation:
13
I have only used REDIM where my program was developing more data to add to an already filled array. Is there a circumstance where REDIM is being used other than to expand an existing array? Can't be used to ReName an existing array can it?
ReDim Array1(50) as Array2(50)
Posts: 1,001
Threads: 50
Joined: May 2022
Reputation:
27
The function of Redim has been discussed ad nauseam here, but somehow it doesn't seem to get through.
Again: A static array is set to zero with Erase. That's all you need. Redim cannot be used here.
A dynamic array is reinitialized with Redim; the dimension cannot be changed. Two-dimensional to three-dimensional is not possible. If Erase is used on a dynamic array, you can't see anything, absolutely nothing, because a dynamic array only exists while the program is running. That's why you can't set it to zero! Erase frees up the array's memory space again; that doesn't work with static arrays.
Redim: Is a combination of Erase and Dim. Without Redim, you would first have to erase a dynamic array with Erase and then reinitialize it with Dim.
Posts: 381
Threads: 56
Joined: Apr 2022
Reputation:
13
I agree with you Kernelpanic, it's got to be trying when it appears we are beating a dead horse, but I do have problems with understanding the nuances of what goes into making a word in a programming language work and ReDim is one which does have me scratching my head. As you say it works with ERASE, which seems to wipe out the existence of the array itself.
If its completely erased, then why would ReDim not also be able to resurrect a new name for the array?
I surmise, some part of the original array (ie the name) must be saved when when you use ReDim.
ERASE with a Dimmed array and that array is completely gone, name and all. Correct?
So the only other use for ReDim, if you are not using it to expand your array with _Preserve, would be to completely wipe out the data of the array and start again to fill the same array with the same number of elements. ( ie saving the name of the array and number of elements). Not sure if that is any more efficient than For x = 1 to 50:Array(x)=0:Next