[SOLVED] Is there a macro that captures the name of the current project? lazarus / 9-Editor ---------------------------------------------------------------------- EganSolo · 2025-07-29 23:24 I tried $(ProjectName), but it wasn't recognized. I'd like to use that macro in defining paths for the compiler. ---------------------------------------------------------------------- Thaddy · 2025-07-30 05:28 No, you have to do that manually. One way of doing this is like so: 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 program testproject;uses prgname; //unit that demo's the availability.const   projectname:pchar = 'testproject'; export name 'projectname';beginend.This constant is now visible in any unit, like so: 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 unit prgname;interface var projectname :Pchar external name 'projectname';implementationinitialization  writeln(projectname);end. The reason for the export is that the constant would otherwise not be visible in the units. The exported name is - officially - Case sensitive, as with any other exports, although it does not seem to matter. Two other options, both more cumbersome: {$define} resourcestring (but the resourcestring must be loaded by hand in other units. Or with a hackery trick) The above is clean and precise. The reason that I use a PChar is that it is not a refcounted string type. shortstring will likely also work. Note that this technique would be very easy to implement in the compiler where it can expand to the filename that is already available to the compiler anyway. Maybe a feature request? People such as Warfely implement this likely in seconds.. (hint, Frederic ) ---------------------------------------------------------------------- ccrause · 2025-07-30 05:42 Quote from: EganSolo on July 30, 2025, 01:24:09 amI tried $(ProjectName), but it wasn't recognized. I'd like to use that macro in defining paths for the compiler. Assuming you are referring to using macros inside the Lazarus IDE, then look at the wiki page for IDE macros. I suspect you need to use $NameOnly($(ProjFile)). ---------------------------------------------------------------------- Thaddy · 2025-07-30 06:04 Yes, the Lazarus ide has support for it, but I use often other editors, hence I filed a feature request: #41348 ---------------------------------------------------------------------- Thaddy · 2025-07-30 13:20 Response from Michael, boils down to 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 {$mode objfpc}beginwriteln(Paramstr(0));end.The Paramstr is also available in units. I think that is enough? Maybe not for every and all scenario's, e.g. like libraries. ---------------------------------------------------------------------- EganSolo · 2025-07-31 03:16 ccrause: You hit it on the nail. I wanted a macro I could use while setting the compiler path. That does it and thank you for the reference. Much appreciated.