Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
REDIM takes more resources than DIM?
#23
(07-17-2024, 08:12 PM)Kernelpanic Wrote: There are problems here, but why? Personally, I think it is wrong to declare an array with ReDim... that is confusing. For me, the clear line is lost.
I think you're getting too caught up in the name `ReDim`, it's potentially a badly chosen command name. `ReDim` does not pair with `Dim`, you can't use `Dim` initially and then use `ReDim` afterwards. Rather, `Dim` and `ReDim` declare different types of arrays, static vs. dynamic. Only dynamic arrays declared using `ReDim` can be subsequently resized by another `ReDim`.

This detail is mentioned on the Wiki page for `ReDim`, though it's about halfway down:

Quote:REDIM cannot change $STATIC arrays created with a DIM statement unless the $DYNAMIC Metacommand is used!
To create a dynamic array use the $DYNAMIC metacommand or use REDIM rather than DIM when first creating the array.
(Note that it does work like you're thinking if you use `$Dynamic`, but IMO you should forget that exists and just use `ReDim`)
Reply


Messages In This Thread
REDIM takes more resources than DIM? - by bplus - 07-17-2024, 12:21 AM
RE: REDIM takes more resources than DIM? - by DSMan195276 - 07-17-2024, 09:24 PM



Users browsing this thread: 14 Guest(s)