dummzeuch 1505 Posted March 21, 2023 (edited) Unit bla; interface type TServerParams = record Url: string; XCoord: Integer; YCoord: Integer; end; TServerParamsArr = array of TServerParams; const ServerParamsArr: TServerParamsArr = ( (Url: 'https://ows.terrestris.de/osm/service'; // <=== XCoord: 529850; YCoord: 5284850), (Url: 'https://geoportal.koblenz.de/geoserver/OEFFENTLICH/ows'; XCoord: (391000 + 408000) div 2; YCoord: (5571000 + 5586000) div 2) ); Given the code above, why do I get a compile error at the line marked with // <=== ? "E2003 Undeclared identifier: 'Url'" This is with Delphi 10.2, just in case that matters. edit: It compiles if I change TServerParamsArray: type TServerParamsArr = array[0..1] of TServerParams; Edited March 21, 2023 by dummzeuch Share this post Link to post
programmerdelphi2k 237 Posted March 21, 2023 I believe that "your definition" itself as a "limited elements" = 2, or be a const have "n" elements in your array, and you dont say "how many" Share this post Link to post
Fr0sT.Brutal 900 Posted March 21, 2023 Array constants with no predefined length never were not allowed Share this post Link to post
Uwe Raabe 2057 Posted March 21, 2023 (edited) 1 hour ago, Fr0sT.Brutal said: Array constants with no predefined length never were not allowed In fact they are: type TStringArr = array of string; const cStringArr: TStringArr = ['Hello', 'World']; Just not with the record element type, because the record constants are not accepted as true constants. Edited March 21, 2023 by Uwe Raabe 4 Share this post Link to post
Fr0sT.Brutal 900 Posted March 22, 2023 (edited) 17 hours ago, Uwe Raabe said: In fact they are: Funny, even after 20 years of Delphiing you can discover something new 🙂 Edit: Alas, that's only for compilers with array literals. Edited March 22, 2023 by Fr0sT.Brutal Share this post Link to post