Recovering variable name lazarus / 21-General ---------------------------------------------------------------------- MarkMLl · 2025-04-07 19:15 Str() can be used to recover the name of a value of an enumerated type. Can it (or something comparable) be used to recover the name of a variable without relying on debug information being appended to the executable? I have a declaration (representing areas of do-not-enter airspace) that looks like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Broadacres: TRegionDegs= ((lat: 50.8952; Lon: 0.1581),                          (Lat: 50.9008; Lon: 0.1746),                            (Lat: 50.8913; Lon: 0.1838),                            (Lat: 50.8844; Lon: 0.1611),                            (lat: 50.8952; Lon: 0.1581));   DeanlandWood: TRegionDegs= ((Lat: 50.8820; Lon: 0.1671),                            (Lat: 50.8860; Lon: 0.1755),                            (Lat: 50.8893; Lon: 0.1884),                            (Lat: 50.8839; Lon: 0.1926),                              (Lat: 50.8809; Lon: 0.1822),                              (Lat: 50.8801; Lon: 0.1694),                              (Lat: 50.8820; Lon: 0.1671));  Now I could obviously redefine TRegionDegs to be a record with a name followed by an array of indeterminate size, but I thought it worth checking first whether there was some implicit capability of the compiler or RTL of which I was not aware. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2025-04-07 19:44 Quote from: MarkMLl on April 07, 2025, 09:15:19 pmCan it (or something comparable) be used to recover the name of a variable without relying on debug information being appended to the executable? No, for variables there is no such thing. ---------------------------------------------------------------------- MarkMLl · 2025-04-08 07:22 Thanks, thought it worth checking. MarkMLl ---------------------------------------------------------------------- jcmontherock · 2025-04-08 09:32 With GetEnumName function ? ---------------------------------------------------------------------- 440bx · 2025-04-08 09:47 Quote from: jcmontherock on April 08, 2025, 11:32:39 amWith GetEnumName function ? That only works for the names of enumerated items not for variables. For variables, the only way at this time to get their name is to get it from the debug symbols and debug symbols cannot be relied since the debugging information may or may not be included in the executable. ---------------------------------------------------------------------- MarkMLl · 2025-04-08 10:27 Quote from: 440bx on April 08, 2025, 11:47:27 amFor variables, the only way at this time to get their name is to get it from the debug symbols and debug symbols cannot be relied since the debugging information may or may not be included in the executable. And I did explicitly exclude using debugging info in OP, since that would make the functionality of a program dependant upon its build mode. In practice, after a bit of experimentation and looking back through a couple of related questions I asked last year, even defining a record containing a constant name and constant array (of arbitrary size) is a problem: PascalDragon explicitly told me that the initialiser in a record can't be dynamic. So I can initialise an array (defining a polygon) with an arbitrary number of elements as a constant. However I can't initialise a record containing that plus a name as a constant, and I can't initialise an array containing that and other polygons as a constant. MarkMLl ---------------------------------------------------------------------- marcov · 2025-04-08 16:48 (cleaned up thread, please report possible spam, don't react or worse, quote it)