<?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 Betreff: How to control value of VALUES{2} through an IF statement? in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/660838#M7644</link>
    <description>&lt;P&gt;As NMK195 said: The "stringified" representation is just there for the user, that's the whole poinf of using it.&lt;/P&gt;
&lt;P&gt;However in your particular case it might make sense to actually check for "min" and "max", since the numbers might change.&lt;/P&gt;
&lt;P&gt;There is hope: you can use this command &lt;SPAN&gt;&lt;SPAN class="scrapt"&gt;&lt;CODE&gt;parvalue_description ("size")&lt;/CODE&gt; to retrieve the string representation.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="scrapt"&gt;I myself would still not use it since string comparisons are very costly &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN class="scrapt"&gt;and it is more elegant to just use a local definition like this (I use all uppercase for constants to better distinguish):&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;!//--in Master script:
EPS = 0.00001
SIZE_MIN = 2.0
SIZE_MAX = 5.5

!//--in Param script:
values{2} "size",
    SIZE_MIN, "min",
    SIZE_MAX, "max"

!//--in 2D/3D then:
!// be aware of floating point inaccuracy !
if abs(size-SIZE_MIN) &amp;lt; EPS then
    !.... do whatever
endif&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="scrapt"&gt;Happy coding!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Apr 2025 10:16:21 GMT</pubDate>
    <dc:creator>runxel</dc:creator>
    <dc:date>2025-04-28T10:16:21Z</dc:date>
    <item>
      <title>How to control value of VALUES{2} through an IF statement?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/660824#M7640</link>
      <description>&lt;P&gt;Hi, this is related to a previous post I've made: &lt;A title="How to hange A &amp;amp; B values of object with an IF script?" href="https://community.graphisoft.com/t5/GDL/How-to-hange-A-amp-B-values-of-object-with-an-IF-script/td-p/660302" target="_blank" rel="noopener"&gt;Link&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry if this is a double post, but the previous post was technically solved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a script where the A and B dimensions are based on two VALUES{2} lists with length parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like the value of VALUES{2} for the B-dimensions to be dependent on VALUES{2} of the A-dimension through an IF statement. Is this possible? I keep getting error messages regarding parameter types with variations of the following parameter&amp;nbsp; script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;VALUES{2} "size" 2.0, "min", &lt;BR /&gt;5.0, "max"&lt;BR /&gt;&lt;BR /&gt;VALUES{2} "width" size*2, "minwidth", &lt;BR /&gt;size*5, "maxwidth"&lt;BR /&gt;&lt;BR /&gt;LOCK "A", "B"&lt;BR /&gt;&lt;BR /&gt;IF size= "max" THEN &lt;BR /&gt;width = "maxwidth"&lt;BR /&gt;ELSE&lt;BR /&gt;width = "minwidth"&lt;BR /&gt;ENDIF&lt;BR /&gt;&lt;BR /&gt;A=size&lt;BR /&gt;B=width&lt;BR /&gt;PARAMETERS A=A, B=B&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 08:59:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/660824#M7640</guid>
      <dc:creator>Bilkins</dc:creator>
      <dc:date>2025-04-28T08:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to control value of VALUES{2} through an IF statement?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/660834#M7641</link>
      <description>&lt;P class=""&gt;Hello!&lt;/P&gt;&lt;P class=""&gt;I am not very proficient in English, so I will use ChatGPT to help translate the message below. If anything is unclear, please feel free to ask me for clarification.&lt;/P&gt;&lt;P class=""&gt;Regarding your code:&lt;/P&gt;&lt;P class=""&gt;For values{2}, "min" and "max" are only display texts, not actual parameter values. Therefore, setting size = "max", width = "maxwidth", or width = "minwidth" is incorrect in terms of parameter types.&lt;/P&gt;&lt;P class=""&gt;Suggested correction:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VALUES{2} "size" 2.0, "min", 
5.0, "max"

VALUES{2} "width" size*2, "minwidth", 
size*5, "maxwidth"

LOCK "A", "B"

EPS = 0.00001
IF abs(size-2) &amp;lt; EPS THEN 
parameters width = 4
ELSE
parameters width = 25
ENDIF

A=size
B=width
PARAMETERS A=A, B=B&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 28 Apr 2025 09:32:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/660834#M7641</guid>
      <dc:creator>NMK195</dc:creator>
      <dc:date>2025-04-28T09:32:03Z</dc:date>
    </item>
    <item>
      <title>Betreff: How to control value of VALUES{2} through an IF statement?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/660838#M7644</link>
      <description>&lt;P&gt;As NMK195 said: The "stringified" representation is just there for the user, that's the whole poinf of using it.&lt;/P&gt;
&lt;P&gt;However in your particular case it might make sense to actually check for "min" and "max", since the numbers might change.&lt;/P&gt;
&lt;P&gt;There is hope: you can use this command &lt;SPAN&gt;&lt;SPAN class="scrapt"&gt;&lt;CODE&gt;parvalue_description ("size")&lt;/CODE&gt; to retrieve the string representation.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="scrapt"&gt;I myself would still not use it since string comparisons are very costly &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN class="scrapt"&gt;and it is more elegant to just use a local definition like this (I use all uppercase for constants to better distinguish):&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;!//--in Master script:
EPS = 0.00001
SIZE_MIN = 2.0
SIZE_MAX = 5.5

!//--in Param script:
values{2} "size",
    SIZE_MIN, "min",
    SIZE_MAX, "max"

!//--in 2D/3D then:
!// be aware of floating point inaccuracy !
if abs(size-SIZE_MIN) &amp;lt; EPS then
    !.... do whatever
endif&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="scrapt"&gt;Happy coding!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 10:16:21 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/660838#M7644</guid>
      <dc:creator>runxel</dc:creator>
      <dc:date>2025-04-28T10:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to control value of VALUES{2} through an IF statement?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/662334#M7695</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used this in my last script:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if n&amp;gt;0 then
	values "A",A_half*2
	values "B",range [1,]
	else 
	values "B",range [1,]
	parameters A=B
endif&lt;/LI-CODE&gt;&lt;P&gt;Before this IF the A and B sizes are not defined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 May 2025 08:46:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/662334#M7695</guid>
      <dc:creator>Domagoj Lukinic</dc:creator>
      <dc:date>2025-05-13T08:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to control value of VALUES{2} through an IF statement?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/662434#M7698</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your 'values' command has an extra comma&lt;BR /&gt;the correct format should be as follows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if n&amp;gt;0 then
	values "A" A_half*2
	values "B" range [1,]
	else 
	values "B" range [1,]
	parameters A=B
endif&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 01:48:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/662434#M7698</guid>
      <dc:creator>NMK195</dc:creator>
      <dc:date>2025-05-14T01:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to control value of VALUES{2} through an IF statement?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/662440#M7699</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;VALUES "parameter_name" [,]value_definition1 [, value_definition2, ...]&lt;/P&gt;&lt;P&gt;you can put comma in "&lt;SPAN&gt;values", its optional.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So it is not an error, it is a matter of preference as far as I know&amp;nbsp; 🤷‍&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 05:53:55 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/662440#M7699</guid>
      <dc:creator>Domagoj Lukinic</dc:creator>
      <dc:date>2025-05-14T05:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to control value of VALUES{2} through an IF statement?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/662551#M7700</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're right, I've never used a comma after 'values' before, so I thought it was incorrect. I tried it again and saw that there's nothing wrong with the code above — the error might be in another line that you didn’t mention earlier. If possible, please upload the file here so everyone can check it more accurately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 May 2025 02:08:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/662551#M7700</guid>
      <dc:creator>NMK195</dc:creator>
      <dc:date>2025-05-15T02:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to control value of VALUES{2} through an IF statement?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/663439#M7737</link>
      <description>&lt;P&gt;the values{2} can take arrays as input, and the ui_infields can take arrays as well. (I know the question was anout values(2}, but those 2 topics are connected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if I have to have dynamic input in either plain entry of the parameter of than in the UI i do something like that:&lt;/P&gt;
&lt;P&gt;prepare 3 arrays: 1 for indexes, 2 for strings, 3 for ui pictures in the master script&lt;/P&gt;
&lt;P&gt;i put every possible entry for those arrays.&lt;/P&gt;
&lt;P&gt;than in the parameter script I double the arrays with different names but with conditional jumps (if.. then...) for the entries that are dynamic&lt;/P&gt;
&lt;P&gt;than either I use values with indexes from parameter script or values{2} with indexes and strings (both parameters from parameter script.&lt;/P&gt;
&lt;P&gt;Finally in the UI in the ui_infield command I use the arrays defined in master script to avoid possible missing entries on some situations - I had all parametric defined arrays in masterscript without the "full" ones, but in some situations that setup could make errors in the UI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 07:28:35 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-control-value-of-VALUES-2-through-an-IF-statement/m-p/663439#M7737</guid>
      <dc:creator>Piotr Dobrowolski</dc:creator>
      <dc:date>2025-05-23T07:28:35Z</dc:date>
    </item>
  </channel>
</rss>

