Forum > Beginners

Using arrays in routines, etc.

(1/5) > >>

CM630:
If I do:



--- 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";}};} ---function a:array of string;beginend;                
it does not compile.
So I usually create a type String1D and then I do


--- 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";}};} ---function a: String1D;beginend;               
This compiles.

But maybe there is a better and an easier way?

Fibonacci:
There isnt.

marcov:
Use types.stringdynarray    Most dynamic arrays of basic types are predefined there.

KodeZwerg:

--- Quote from: Fibonacci on February 22, 2024, 10:47:50 am ---There isnt.

--- End quote ---

--- 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(bar: array of whatever);

Fibonacci:

--- Quote from: KodeZwerg on February 22, 2024, 12:10:29 pm ---
--- Quote from: Fibonacci on February 22, 2024, 10:47:50 am ---There isnt.

--- End quote ---

--- 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(bar: array of whatever);
--- End quote ---

As a result?

Navigation

[0] Message Index

[#] Next page

Go to full version