Forum > Beginners

Resizing arrays.

<< < (2/2)

Zoran:
Read this post from long time ago. The link there seems to be still valid.

There has always been a lot of confusion with open array parameters and dynamic arrays.

Thaddy:
Indeed. I remember that I also answered such a question before.

PascalDragon:

--- Quote from: jamie on January 14, 2022, 01:22:00 am ---if you mean something like this


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Setit(var X:Array of Byte);begin  SetLength(X,100);end;                        ?
 No, it does not compile in 3.0.4 nor 3.2.0
 states it's a type mismatch.

 vary interesting ...
--- End quote ---

Cause that's an open array and not a dynamic array. They are two different things.

engkin:

--- Quote from: PascalDragon on January 14, 2022, 09:14:42 pm ---Cause that's an open array and not a dynamic array. They are two different things.

--- End quote ---

But they look identical  ::)

Kays:

--- Quote from: engkin on January 14, 2022, 09:58:56 pm ---
--- Quote from: PascalDragon on January 14, 2022, 09:14:42 pm ---Cause that's an open array and not a dynamic array. They are two different things.

--- End quote ---
But they look identical  ::)

--- End quote ---
That’s terrible enough. I fell for that a couple times, too. Don’t ask me why TP7 introduced that syntax. Back then the ISO standards 7185 (level 1) and 10206 already defined conformant array parameters which look like this:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure foo(data: array[dataIndexMinimum..dataIndexMaximun: integer] of char);

Navigation

[0] Message Index

[*] Previous page

Go to full version