Jump to content
Sign in to follow this  
dummzeuch

Why is Url an undeclared identifier here?

Recommended Posts

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 by dummzeuch

Share this post


Link to post

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
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 by Uwe Raabe
  • Thanks 4

Share this post


Link to post
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 by Fr0sT.Brutal

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×