<?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: Issue with incrementing an integer in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366465#M559</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Running parameter script only once might be a matter of taste. It forces writing code that makes the distinction between parameters and variables, so it is more work from start, but will help understanding the code when new features are added to parameters dependent on eachother.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If run only once is not used, checking "firstoccasion_in_progress" can be necessary with GLOB_MODPAR_NAME, because it is always the name of the parameter modified by the user, not the ones modified with the PARAMETERS command.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Jan 2023 08:57:27 GMT</pubDate>
    <dc:creator>Peter Baksa</dc:creator>
    <dc:date>2023-01-02T08:57:27Z</dc:date>
    <item>
      <title>Issue with incrementing an integer</title>
      <link>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366288#M556</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having the weirdest of issues on Archicad 24 7006 FULL trying to increment a integer value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have this very simple code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if check then
	test = test + 1
	parameters test = test
endif&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;check&lt;/EM&gt; is a checkbox&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;test&lt;/EM&gt; is an integer&lt;/P&gt;&lt;P&gt;- I want to increment &lt;EM&gt;test&lt;/EM&gt; every time I check the box&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I go to the Parameters list, every time I check the box, the increment is done twice... No matter the value, it will double the increment (if I do &lt;EM&gt;test = test + 10&lt;/EM&gt;, it will increment by 20). So if I want to increment &lt;EM&gt;test&lt;/EM&gt; by 1, I need to do use a dummy Real number, do the increment on&lt;EM&gt; dummy&lt;/EM&gt; and then round_int() it to &lt;EM&gt;test.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is no other code anywhere else. I tested that code alone in Main script and also alone in Parameter script for the same results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What exactly am I doing wrong ? I've been at it for an hour now and I don't see it &lt;span class="lia-unicode-emoji" title=":loudly_crying_face:"&gt;😭&lt;/span&gt; Seems super obvious&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grimacing_face:"&gt;😬&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 13:59:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366288#M556</guid>
      <dc:creator>MetalFingerz</dc:creator>
      <dc:date>2022-12-29T13:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with incrementing an integer</title>
      <link>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366295#M557</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;	if check then
		test = test + 1
		parameters test = test
		PARAMETERS check = 0
	endif&lt;/LI-CODE&gt;&lt;P&gt;This works for me.&lt;BR /&gt;Also there is a checkbox "run parameter script always once" in the compatibilty options.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 15:39:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366295#M557</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2022-12-29T15:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with incrementing an integer</title>
      <link>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366342#M558</link>
      <description>&lt;P&gt;All the time that your check box is turned on, it will increment the 'test' parameter every time the script is run.&lt;/P&gt;
&lt;P&gt;And as you have discovered the parameter/mater script is run more than once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, as Joachim suggests, reset your checkbox to zero (off) once you have incremented the 'test' parameter.&lt;/P&gt;
&lt;P&gt;This should solve the issue as he also mentions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As well as the option in the compatibility options (I think this forces the entire parameter script to only run once - which I have never worked out if it is a good or bad thing, and I don't think it is very well documented anywhere what actually happens - maybe I just haven't looked hard enough), there is also a GDL command ... n = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)&lt;/P&gt;
&lt;P&gt;So you can use the value returned in 'isFirstRun' to determine if it is the first time the script has run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can look it up in the GDL reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 06:53:02 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366342#M558</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2022-12-30T06:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with incrementing an integer</title>
      <link>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366465#M559</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Running parameter script only once might be a matter of taste. It forces writing code that makes the distinction between parameters and variables, so it is more work from start, but will help understanding the code when new features are added to parameters dependent on eachother.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If run only once is not used, checking "firstoccasion_in_progress" can be necessary with GLOB_MODPAR_NAME, because it is always the name of the parameter modified by the user, not the ones modified with the PARAMETERS command.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2023 08:57:27 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366465#M559</guid>
      <dc:creator>Peter Baksa</dc:creator>
      <dc:date>2023-01-02T08:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with incrementing an integer</title>
      <link>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366568#M560</link>
      <description>&lt;P&gt;So I ended up doing the solution from Joachim.&lt;/P&gt;&lt;P&gt;I did not have the parameter script ran once though because my inputs were lagging (by a run) and because I'm putting pictures on checkboxes, so them not being checked visually was not an issue.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 11:10:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366568#M560</guid>
      <dc:creator>MetalFingerz</dc:creator>
      <dc:date>2023-01-03T11:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with incrementing an integer</title>
      <link>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366584#M561</link>
      <description>&lt;P&gt;Just realized that all what you guys said was written in the Reference Guide on page 559 &lt;span class="lia-unicode-emoji" title=":downcast_face_with_sweat:"&gt;😓&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;Therefore it makes no sense to increase a parameter value by one in the parameter script since you may not be able to predict the cardinality of executions.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The run of the parameter script is linear, and not necessarily multiple. You can force the parameter script to start only once by checking the Run the parameter script only once option in the object's Compatibility Options panel, if you are sure you don't need it to run many times. This can make objects react faster, saving time and computing resources.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Classic case of RTFM &lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 16:34:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Issue-with-incrementing-an-integer/m-p/366584#M561</guid>
      <dc:creator>MetalFingerz</dc:creator>
      <dc:date>2023-01-03T16:34:25Z</dc:date>
    </item>
  </channel>
</rss>

