<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Graphisoft Resource Compiler: how to set up macros in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/401310#M8663</link>
    <description>&lt;P&gt;Hi Sam,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;EM&gt;ResConv.doc&lt;/EM&gt; help is not very clear about it, but I think you can only define if a variable as a flag and check if it's there with "#ifdef".&lt;/P&gt;
&lt;P&gt;I don't think you can give it an actual value like you did and then use that value.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/15844"&gt;@Sam Karli&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;BTW for me the #include in .grc files don't work, neither, see&amp;nbsp;&lt;A href="https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/td-p/321954" target="_blank" rel="noopener"&gt;https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/td-p/321954&lt;/A&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I can't answer in that thread since it's locked, so I'm answering here. I don't think that the issue is with #includes, but that you are using the substitution wrong. First of all, the substitution of defined macros happens not during the &lt;EM&gt;ResConv.exe&lt;/EM&gt; step but later using the Windows Resource Compiler (&lt;EM&gt;rc.exe&lt;/EM&gt;). &lt;BR /&gt;And second,&amp;nbsp;&lt;CODE&gt;APP_NAME&lt;/CODE&gt; is not substituted there because the substitution you are trying doesn't work in strings. (and I also think that it's wrong to use "@"-signs around the defined macro).&lt;BR /&gt;What would work is to substitute numbers like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#define NUMBER_MACRO 32520  // This could also be in an include file
//...
'STR#' NUMBER_MACRO "Prompt strings" {
/* [ ] */ "This has to be a fixed string before it goes to ResConv.exe"
/* [ ] */ "This too"
}&lt;/LI-CODE&gt;
&lt;P&gt;But I guess that won't help in your case.&lt;BR /&gt;&lt;BR /&gt;Now from your questions I'm guessing that you want variable strings in your resources. I see two options:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Do some string replacement processing even before the &lt;EM&gt;ResConv.exe&lt;/EM&gt; step.&lt;BR /&gt;I do this for my "APP_NAME" in my projects. But I'm using CMake configure and so the specifics won't help in your case. So you'll have to research how to do that for Visual Studio projects/solutions.&lt;/LI&gt;
&lt;LI&gt;Define the string with the intention to do the substitution later in the code. So something like this:&lt;BR /&gt;&lt;LI-CODE lang="c"&gt;// This is the resource file
'STR#' 32520 "Prompt strings" {
/* [ ] */ "The following will be replaced: %s"
/* [ ] */ "Normal String"
}​&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;// This is some code file where you access the resource
GS::UniString format;
RSGetIndString (&amp;amp;format, 32520, 1, ACAPI_GetOwnResModule ());
GS::UniString substitutedString = GS::UniString::Printf (format, "MySuperAppName");
// Substituted string should now be "The following will be replaced: MySuperAppName"&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps!&lt;/P&gt;
&lt;P&gt;Bernd&lt;/P&gt;</description>
    <pubDate>Sat, 07 Oct 2023 09:07:33 GMT</pubDate>
    <dc:creator>BerndSchwarzenbacher</dc:creator>
    <dc:date>2023-10-07T09:07:33Z</dc:date>
    <item>
      <title>Graphisoft Resource Compiler: how to set up macros</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/400922#M8646</link>
      <description>&lt;P&gt;ResConv.exe doc mentions that macros can be defined using&amp;nbsp;[-d &amp;lt;ID1&amp;gt;] [-d &amp;lt;ID2&amp;gt;] [...] [-d &amp;lt;IDn&amp;gt;] formula.&lt;/P&gt;
&lt;P&gt;I'm making experiments with it and couldn't make it work.&lt;BR /&gt;The command line looks like this:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;lt;Command Condition="'$(BuildType)'=='Debug'"&amp;gt;"$(ACDevKitSupport)\Tools\Win\ResConv.exe" -m r -D WINDOWS -T W -q utf8 1252 -i "RINT\$(ProjectName).grc" -D _DEBUG &lt;STRONG&gt;-D COMPANY_NAME="$(CompanyName)"&lt;/STRONG&gt; -o "$(OutDir)\RO\$(ProjectName).grc.rc2"&amp;lt;/Command&amp;gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;But this (and many variations for this) doesn't work.&amp;nbsp;What is the decipherment of this enigma?&lt;/P&gt;
&lt;P&gt;BTW for me the #include in .grc files don't work, neither, see&amp;nbsp;&lt;A href="https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/td-p/321954" target="_blank" rel="noopener"&gt;https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/td-p/321954&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 12:26:56 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/400922#M8646</guid>
      <dc:creator>Sam Karli</dc:creator>
      <dc:date>2024-09-16T12:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Graphisoft Resource Compiler: how to set up macros</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/401310#M8663</link>
      <description>&lt;P&gt;Hi Sam,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;EM&gt;ResConv.doc&lt;/EM&gt; help is not very clear about it, but I think you can only define if a variable as a flag and check if it's there with "#ifdef".&lt;/P&gt;
&lt;P&gt;I don't think you can give it an actual value like you did and then use that value.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/15844"&gt;@Sam Karli&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;BTW for me the #include in .grc files don't work, neither, see&amp;nbsp;&lt;A href="https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/td-p/321954" target="_blank" rel="noopener"&gt;https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/td-p/321954&lt;/A&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I can't answer in that thread since it's locked, so I'm answering here. I don't think that the issue is with #includes, but that you are using the substitution wrong. First of all, the substitution of defined macros happens not during the &lt;EM&gt;ResConv.exe&lt;/EM&gt; step but later using the Windows Resource Compiler (&lt;EM&gt;rc.exe&lt;/EM&gt;). &lt;BR /&gt;And second,&amp;nbsp;&lt;CODE&gt;APP_NAME&lt;/CODE&gt; is not substituted there because the substitution you are trying doesn't work in strings. (and I also think that it's wrong to use "@"-signs around the defined macro).&lt;BR /&gt;What would work is to substitute numbers like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#define NUMBER_MACRO 32520  // This could also be in an include file
//...
'STR#' NUMBER_MACRO "Prompt strings" {
/* [ ] */ "This has to be a fixed string before it goes to ResConv.exe"
/* [ ] */ "This too"
}&lt;/LI-CODE&gt;
&lt;P&gt;But I guess that won't help in your case.&lt;BR /&gt;&lt;BR /&gt;Now from your questions I'm guessing that you want variable strings in your resources. I see two options:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Do some string replacement processing even before the &lt;EM&gt;ResConv.exe&lt;/EM&gt; step.&lt;BR /&gt;I do this for my "APP_NAME" in my projects. But I'm using CMake configure and so the specifics won't help in your case. So you'll have to research how to do that for Visual Studio projects/solutions.&lt;/LI&gt;
&lt;LI&gt;Define the string with the intention to do the substitution later in the code. So something like this:&lt;BR /&gt;&lt;LI-CODE lang="c"&gt;// This is the resource file
'STR#' 32520 "Prompt strings" {
/* [ ] */ "The following will be replaced: %s"
/* [ ] */ "Normal String"
}​&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;// This is some code file where you access the resource
GS::UniString format;
RSGetIndString (&amp;amp;format, 32520, 1, ACAPI_GetOwnResModule ());
GS::UniString substitutedString = GS::UniString::Printf (format, "MySuperAppName");
// Substituted string should now be "The following will be replaced: MySuperAppName"&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps!&lt;/P&gt;
&lt;P&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Sat, 07 Oct 2023 09:07:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/401310#M8663</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2023-10-07T09:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Graphisoft Resource Compiler: how to set up macros</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/401734#M8683</link>
      <description>&lt;P&gt;Thanks for Your detailed answer,&lt;/P&gt;
&lt;P&gt;some thoughts:&lt;/P&gt;
&lt;P&gt;-using cmake seems to be a good idea since Graphisoft is moving towards this approach (see devkit/Examples). Unfortunately I'm absolutely a beginner in this topic but this is a strong argument that I should pick this up&lt;/P&gt;
&lt;P&gt;-regarding &lt;EM&gt;"@SOME_MACRO@"&lt;/EM&gt;-style stuff, I've seen this in a live code (but didn't work for me), but I think the developer is in my network and can say how it worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Sam&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 06:45:30 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/401734#M8683</guid>
      <dc:creator>Sam Karli</dc:creator>
      <dc:date>2023-10-10T06:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Graphisoft Resource Compiler: how to set up macros</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/401787#M8686</link>
      <description>&lt;P&gt;Hi Sam,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- I think CMake is definitely worth the investment. Especially if you want to compile your Add-Ons for both macOS and Windows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- The&amp;nbsp; "@SOME_MACRO@" stuff is actually how you can do substitution in CMake via the &lt;A href="https://cmake.org/cmake/help/latest/command/configure_file.html" target="_self"&gt;configure_file&lt;/A&gt; function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 08:34:35 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-how-to-set-up-macros/m-p/401787#M8686</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2023-10-11T08:34:35Z</dc:date>
    </item>
  </channel>
</rss>

