Forum > General

Constant initialisation: dynamic array of dynamic arrays

(1/1)

MarkMLl:
I think somebody asked something like this recently, but I can't find it and for that I apologise.

I'm trying to do 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";}};} ---type (* Assume that these are convertible but not directly compatible.               *)   TVertexDegs= record                 lat, lon: double               end;  TVertexRads= record                 lat, lon: double               end;  TRegionDegs= array of TVertexDegs;  TRegionRads= array of TVertexRads;  TRegionsDegs= array of TRegionDegs;  TRegionsRads= array of TRegionRads; ...  Broadacres: TRegionDegs= ((Lat: 0.0; Lon: 0.0),                           (Lat: 0.0; Lon: 0.0));   DeanlandWood: TRegionDegs= ((Lat: 0.0; Lon: 0.0),                              (Lat: 0.0; Lon: 0.0));   RipeVillage: TRegionDegs= ((Lat: 0.0; Lon: 0.0),                             (Lat: 0.0; Lon: 0.0));   Kittyhawk: TRegionDegs= ((Lat: 0.0; Lon: 0.0),                           (Lat: 0.0; Lon: 0.0));   Avoids: TRegionsDegs= (Broadacres, DeanlandWood, Kittyhawk, RipeVillage); 
What is the correct syntax for that final line that sets up and array-of-arrays-of records?

In practice this will se set up from a .ini file, but I'm trying to do something Q&D for testing.

MarkMLl

PascalDragon:

--- Quote from: MarkMLl on June 05, 2024, 09:11:14 am ---What is the correct syntax for that final line that sets up and array-of-arrays-of records?
--- End quote ---

Initializers need to be untyped constants. As records can't be untyped constants you can't use another record constant as an initializer. Thus you need to declare the constants for the records inline inside your array.

MarkMLl:

--- Quote from: PascalDragon on June 06, 2024, 10:06:54 pm ---Initializers need to be untyped constants. As records can't be untyped constants you can't use another record constant as an initializer. Thus you need to declare the constants for the records inline inside your array.

--- End quote ---

Thanks for that. I'd moved to building it at runtime out of predefined arrays-of-records so in practice had not lost a great deal of time.

At some point everything will be initialised from .ini files, so what I was asking was really only a temporary hack anyway.

MarkMLl

Navigation

[0] Message Index

Go to full version