<?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: Multiple nested IF-THEN commands to simulate AND/OR in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583345#M6152</link>
    <description>&lt;P&gt;What do you mean by "G&lt;SPAN&gt;DL has no IFS or AND/OR/NOT options"?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;GDL does have AND, OR and NOT structure (not() is a function).&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2024 17:48:48 GMT</pubDate>
    <dc:creator>Miha Nahtigal</dc:creator>
    <dc:date>2024-01-09T17:48:48Z</dc:date>
    <item>
      <title>Multiple nested IF-THEN commands to simulate AND/OR</title>
      <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583342#M6151</link>
      <description>&lt;P&gt;Just when I think I've got the hang of these, I get a really complicated one I can't seem to fix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;GDL has no IFS or AND/OR/NOT options, so every condition has to be covered with a separate if statement.&lt;/P&gt;
&lt;P&gt;I can make this work - up to a point. More than a couple of combinations and my script fails.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to script something like:&lt;/P&gt;
&lt;P&gt;If option 1 is true, then if option 2 is also true - do x, but if option 1 is true and option 2 is not true - do y.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What &lt;EM&gt;almost&lt;/EM&gt; worked is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if detailOpt_2D_1=1 then 															! if draw chamber selected AND
	if 	detailOpt_2D=1 then															! if draw outer wall also selected AND
		if drawConnectors=1 then ui_pict "GDL_UI_2d_4_1", 240, 60, 210, 190, 1		! if connectors also selected -&amp;gt; ui picture: cover + chamber + wall + connectors **works**
		else		
		if drawConnectors=0 then ui_pict "GDL_UI_2d_4", 240, 60, 210, 190, 1		! if connectors not selected -&amp;gt; ui picture: cover + chamber + wall  **doesn't work**
	if detailOpt_2D=0	then														! OR if draw outer wall not selected  
		if drawConnectors=1 then ui_pict "GDL_UI_2d_2_1", 240, 60, 210, 190, 1		! if connectors also selected -&amp;gt; ui picture: cover + chamber with connectors  **works**		
		if drawConnectors=0 then ui_pict "GDL_UI_2d_2", 240, 60, 210, 190, 1		! if connectors not selected -&amp;gt; ui picture: cover + chamber **works**	
	endif
	endif
endif	

	if detailOpt_2D_1=0 then 															! if draw chamber not selected AND
	if 	detailOpt_2D=1 then															! if draw outer wall selected AND
		if drawConnectors=1 then ui_pict "GDL_UI_2d_3_1", 240, 60, 210, 190, 1		! if connectors selected -&amp;gt; ui picture: cover + wall + connectors **works**
		else		
		if drawConnectors=0 then ui_pict "GDL_UI_2d_3", 240, 60, 210, 190, 1		! if connectors not selected -&amp;gt; ui picture: cover + wall **doesn't work**
	if detailOpt_2D=0	then														! OR if draw wall not selected 
		if drawConnectors=1 then ui_pict "GDL_UI_2d_1_1", 240, 60, 210, 190, 1		! if connectors also selected -&amp;gt; ui picture: cover + connectors **works**
		if drawConnectors=0 then ui_pict "GDL_UI_2d_1", 240, 60, 210, 190, 1		! if connectors not selected -&amp;gt; ui picture: cover **works**
	endif
	endif
endif	&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;You'll need to paste this into &amp;nbsp;a document with a wider display to see the structure properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what the dialog looks like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-01-09 at 17.27.11.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/51726i176588B8A13FA77A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2024-01-09 at 17.27.11.png" alt="Screenshot 2024-01-09 at 17.27.11.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I want to display different UI pictures in the interface depending on a combination of user options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The ELSE lines are screwing it up - everything else seems to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried breaking it down into distinct separate lines, but the combinations of options are problematic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been wrestling with this for hours now and everything I do to it just makes it worse!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What am I doing wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 11:27:45 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583342#M6151</guid>
      <dc:creator>Jim Allen</dc:creator>
      <dc:date>2024-09-26T11:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple nested IF-THEN commands to simulate AND/OR</title>
      <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583345#M6152</link>
      <description>&lt;P&gt;What do you mean by "G&lt;SPAN&gt;DL has no IFS or AND/OR/NOT options"?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;GDL does have AND, OR and NOT structure (not() is a function).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 17:48:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583345#M6152</guid>
      <dc:creator>Miha Nahtigal</dc:creator>
      <dc:date>2024-01-09T17:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple nested IF-THEN commands to simulate AND/OR</title>
      <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583346#M6153</link>
      <description>&lt;P&gt;Really?&lt;/P&gt;
&lt;P&gt;For some reason I haven't seen that in the reference, and I've looked at a lot of documentation about &amp;nbsp; - thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 18:23:21 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583346#M6153</guid>
      <dc:creator>Jim Allen</dc:creator>
      <dc:date>2024-01-09T18:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple nested IF-THEN commands to simulate AND/OR</title>
      <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583349#M6154</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/4882"&gt;@Jim Allen&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why not use some kind of bitset ? Seems like you don't have that many options and they all are boolean so you can just create boolean variables that you set at 0 or 1 then you calculate the overall score and according to that total, you display what you need ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Option_A = 1
Option_B = 1
Option_C = 0
Option_D = 0

SCORE = Option_A + Option_B*2 + Option_C*4 + Option_D*8

if SCORE = 0 then ui_pict
if SCORE = 1 then ui_pict
! ...
if SCORE = 15 then ui_pict&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Probably more verbose but it's likely cleaner at the end than many IF with AND or OR&lt;/P&gt;&lt;P&gt;You could even use the BITSET function even though in my opinion, the syntax of that function makes it more complicated than flat out using boolean variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;SCORE = 0
dim my_list[4]
	my_list[1] = 1	! true 
	my_list[2] = 1	! true
	my_list[3] = 0	! false
	my_list[4] = 0	! false

for option = 1 to vardim1(my_list)
	SCORE = bitset(SCORE, option - 1, my_list[option])
next option

if SCORE = 0 then ui_pict
if SCORE = 1 then ui_pict
! ...
if SCORE = 15 then ui_pict&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 19:22:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583349#M6154</guid>
      <dc:creator>MF BIM</dc:creator>
      <dc:date>2024-01-09T19:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple nested IF-THEN commands to simulate AND/OR</title>
      <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583378#M6157</link>
      <description>&lt;P&gt;Why is the &lt;EM&gt;ELSE&amp;nbsp;&lt;/EM&gt;even there? Your description of the IF statement following it says that it should include "Wall", but it since it is after the ELSE, it only queries when detailOp_2D is 0... This also makes the "IF detailOpt_2d = 0" redundant, unless it is more than just a boolean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if detailOpt_2D_1=1 then 										! Chamber
	if detailOpt_2D=1 then											! Wall
			if drawConnectors=1 then ui_pict "GDL_UI_2d_4_1", 240, 60, 210, 190, 1				! Connector	
			if drawConnectors=0 then ui_pict "GDL_UI_2d_4", 240, 60, 210, 190, 1				! No Connector
		else												! No Wall
			if drawConnectors=1 then ui_pict "GDL_UI_2d_2_1", 240, 60, 210, 190, 1				! Connector		
			if drawConnectors=0 then ui_pict "GDL_UI_2d_2", 240, 60, 210, 190, 1				! No Connector	
	endif
endif	

if detailOpt_2D_1=0 then 										! No Chamber
	if detailOpt_2D=1 then											! Wall
			if drawConnectors=1 then ui_pict "GDL_UI_2d_3_1", 240, 60, 210, 190, 1				! Connector		
			if drawConnectors=0 then ui_pict "GDL_UI_2d_3", 240, 60, 210, 190, 1				! No Connector
		else												! No Wall 
			if drawConnectors=1 then ui_pict "GDL_UI_2d_1_1", 240, 60, 210, 190, 1				! Connector
			if drawConnectors=0 then ui_pict "GDL_UI_2d_1", 240, 60, 210, 190, 1				! No Connector
	endif
endif	&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Ling.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 02:13:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583378#M6157</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2024-01-10T02:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple nested IF-THEN commands to simulate AND/OR</title>
      <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583426#M6162</link>
      <description>&lt;P&gt;I know &amp;nbsp;it seems to make no sense, but if I take it out, more things break!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've &amp;nbsp;never seen any documentation anywhere mentioning using AND/OR in flow control statements, but they work really well and I think are a great solution to complex flow control statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I made it work properly using this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;	! --------------- select UI picture based on dialog options -----------------------
	if detailOpt_2D_1=0 AND detailOpt_2D=1 AND drawConnectors=1 then ui_pict "GDL_UI_2d_3_1", 240, 60, 210, 190, 1	
	if detailOpt_2D_1=0 AND detailOpt_2D=1 AND drawConnectors=0 then ui_pict "GDL_UI_2d_3", 240, 60, 210, 190, 1	
	if detailOpt_2D_1=0 AND detailOpt_2D=0 AND drawConnectors=1 then ui_pict "GDL_UI_2d_1_1", 240, 60, 210, 190, 1	
	if detailOpt_2D_1=0 AND detailOpt_2D=0 AND drawConnectors=0 then ui_pict "GDL_UI_2d_1", 240, 60, 210, 190, 1	

	if detailOpt_2D_1=1 AND detailOpt_2D=1 AND drawConnectors=1 then ui_pict "GDL_UI_2d_4_1", 240, 60, 210, 190, 1	
	if detailOpt_2D_1=1 AND detailOpt_2D=1 AND drawConnectors=0 then ui_pict "GDL_UI_2d", 240, 60, 210, 190, 1	
	if detailOpt_2D_1=1 AND detailOpt_2D=0 AND drawConnectors=1 then ui_pict "GDL_UI_2d_2_1", 240, 60, 210, 190, 1	
	if detailOpt_2D_1=1 AND detailOpt_2D=0 AND drawConnectors=0 then ui_pict "GDL_UI_2d_2", 240, 60, 210, 190, 1&lt;/LI-CODE&gt;
&lt;P&gt;It's so much easier to read and script - much, much cleaner, and works perfectly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Elsewhere I was able to replace this:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if ZZYZX&amp;lt;0.901 then	
	if max(numBranches, numBranches2)=3 then 		! if depth&amp;gt;0.9 AND 3 branches on 1 side
		ChamberLength=1.03 
	else											! otherwise if 						
		if  max(numBranches, numBranches2)&amp;gt;3 then	! there are &amp;gt;3 branches on any side
		ChamberLength=1.37							
		else 	
		ChamberLength= 0.8
		endif
	endif
endif&lt;/LI-CODE&gt;
&lt;P&gt;with this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if ZZYZX&amp;lt;0.901 AND max(numBranches, numBranches2)&amp;lt;3 then ChamberLength=0.8
if ZZYZX&amp;lt;0.901 AND max(numBranches, numBranches2)=3 then ChamberLength=1.03 
if ZZYZX&amp;lt;0.901 AND max(numBranches, numBranches2)&amp;gt;3 then ChamberLength=1.37 
if ZZYZX&amp;gt;0.9 AND max(numBranches, numBranches2)&amp;lt;4 then ChamberLength=1.25 
if ZZYZX&amp;gt;0.9 AND max(numBranches, numBranches2)&amp;gt;3 then ChamberLength=1.37 &lt;/LI-CODE&gt;
&lt;P&gt;Which works much better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However I really like MF BIM's bitset approach - I might be using that for my next object&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 12:52:43 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583426#M6162</guid>
      <dc:creator>Jim Allen</dc:creator>
      <dc:date>2024-01-10T12:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple nested IF-THEN commands to simulate AND/OR</title>
      <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583446#M6163</link>
      <description>&lt;P&gt;That's a really interesting approach I hadn't thought of - thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 14:31:30 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/583446#M6163</guid>
      <dc:creator>Jim Allen</dc:creator>
      <dc:date>2024-01-10T14:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple nested IF-THEN commands to simulate AND/OR</title>
      <link>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/584281#M6190</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if-else is not as flexible in GDL as in other languages.&lt;/P&gt;
&lt;P&gt;There are two kind of &lt;EM&gt;if &lt;/EM&gt;statements&lt;STRONG&gt;: &lt;/STRONG&gt;single-line and multi-line.&lt;/P&gt;
&lt;P&gt;Multi-line if must have this form (newlines are important, indentation is not):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if condition then&lt;BR /&gt;   statement&lt;BR /&gt;[else&lt;BR /&gt;   statement]&lt;BR /&gt;endif&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When statement is on the same line as &lt;EM&gt;if&lt;/EM&gt;, it is considered a single-line if, and the &lt;EM&gt;else &lt;/EM&gt;might belong to an other &lt;EM&gt;if&lt;/EM&gt; than you intended:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if condition1 then&lt;BR /&gt;    if condition2 then statement1&lt;BR /&gt;else ! this belongs to condition1 because the previous line is a one-line if, no matter how you indent this line&lt;BR /&gt;    statament2&lt;BR /&gt;endif&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 03:11:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Multiple-nested-IF-THEN-commands-to-simulate-AND-OR/m-p/584281#M6190</guid>
      <dc:creator>Peter Baksa</dc:creator>
      <dc:date>2024-01-23T03:11:03Z</dc:date>
    </item>
  </channel>
</rss>

