<?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: Loop Parameter Reset in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278266#M4925</link>
    <description>if it's forbidden to repeat x=1 or use new parameter, n=5 like this:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;FOR i = 1 to n step 1
	If i = 3 then x = 5 then
	text2	y,	0,	x
	x=1
	endif
	text2	y,	0,	x
next i&lt;/PRE&gt;

maybe if you know precisely when it occurs just exclude from the loop? (though it looks awful)&lt;BR /&gt;
FOR i=1 to 2 ...&lt;BR /&gt;
if i=3 then ...&lt;BR /&gt;
FOR i=4 to n ...</description>
    <pubDate>Wed, 09 Sep 2020 07:17:10 GMT</pubDate>
    <dc:creator>A_ Smith</dc:creator>
    <dc:date>2020-09-09T07:17:10Z</dc:date>
    <item>
      <title>Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278255#M4914</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;If I have a loop of &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;1 to N utilising the parameter &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;X=A, where &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;A is some previously defined value, is it possible to pick out when &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;i=G then X=B without needing to save &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;A to a new parameter so that for other steps the original value is still utilised?&lt;BR /&gt;&lt;BR /&gt;Simplified example:&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;!======THESE TWO LINES CANNOT BE INCLUDED IN THE LOOP======
x = 1
n = 5
!===========================================================

FOR i = 1 to n step 1

	If i = 3 then x = 5
	text2	y,	0,	x

next i&lt;/PRE&gt;
&lt;PRE&gt;Returns:	1	1	5	5	5
Desired:	1	1	5	1	1&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Ling.&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;&lt;STRONG&gt;EDIT: Clarified that &lt;I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;X is outside of the loop.&lt;I&gt;&lt;/I&gt;&lt;BR /&gt;&lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;&lt;STRONG&gt;EDIT 2: Wow... I am really good at manually writing out the correct return figures...&lt;/STRONG&gt;&lt;I&gt;&lt;/I&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 26 Sep 2022 20:43:17 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278255#M4914</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2022-09-26T20:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278256#M4915</link>
      <description>Just put an IF statement in your loop?&lt;BR /&gt;
Unless I am not understanding what you need.&lt;BR /&gt;

&lt;PRE&gt;for i = 1 to n
X=A
if i = G then
X=B
endif
next i&lt;/PRE&gt;

&lt;BR /&gt;
Barry.</description>
      <pubDate>Tue, 08 Sep 2020 09:07:00 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278256#M4915</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2020-09-08T09:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278257#M4916</link>
      <description>Doesn't that change the value of X for all proceeding steps? Or has my understanding of inline definitions been flawed this whole time... I am not up to needing this yet except for when &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;i = N&lt;E&gt;&lt;/E&gt; where N is the final use of that value, so a none issue, but the situation popped up into my head and made a few knots...&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ling.&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;&lt;B&gt;EDIT : Modified original post to clarify details&lt;/B&gt;&lt;E&gt;&lt;/E&gt;</description>
      <pubDate>Tue, 08 Sep 2020 09:15:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278257#M4916</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2020-09-08T09:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278258#M4917</link>
      <description>&lt;BLOCKQUOTE&gt;Lingwisyer wrote:&lt;BR /&gt;
Doesn't that change the value of X for all proceeding steps? 
&lt;/BLOCKQUOTE&gt;

&lt;BR /&gt;
X can only ever equal one value.&lt;BR /&gt;
I thought you just wanted to trap a certain count or point in the loop.&lt;BR /&gt;
&lt;BR /&gt;
You can reset the value of X as you go through the script.&lt;BR /&gt;
It shouldn't affect where it has been used already but will all future uses.&lt;BR /&gt;
This is assuming you are not resetting the actual parameter value.&lt;BR /&gt;
&lt;BR /&gt;
Whenever I change a value I always store an original version of it.&lt;BR /&gt;

&lt;PRE&gt;X=10
X_orig = X
X=20&lt;/PRE&gt;

Then if ever I need to go back to the original value...&lt;BR /&gt;

&lt;PRE&gt;X= X_orig &lt;/PRE&gt;

&lt;BR /&gt;
&lt;BR /&gt;
Maybe I don't understand exactly what you want after all.&lt;BR /&gt;
&lt;BR /&gt;
Barry.</description>
      <pubDate>Tue, 08 Sep 2020 09:41:08 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278258#M4917</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2020-09-08T09:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278259#M4918</link>
      <description>Your error was in the conditional statement location&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;
x = 1
n = 5

FOR i = 1 to n step 1
	If i = 3 then
		x = 5
	endif

	text2	y,	0,	x
next i

&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Sep 2020 10:17:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278259#M4918</guid>
      <dc:creator>Nader Belal</dc:creator>
      <dc:date>2020-09-08T10:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278260#M4919</link>
      <description>&lt;BLOCKQUOTE&gt;Moonlight wrote:&lt;BR /&gt;
Your error was in the conditional statement location&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;
x = 1
n = 5

FOR i = 1 to n step 1
	If i = 3 then
		x = 5
	endif

	text2	y,	0,	x
next i

&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;BR /&gt;
That just shifts the number change. Does not isolate it. I will probably just end up making a new set a parameters to temporarily store the relevant values.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ling.</description>
      <pubDate>Wed, 09 Sep 2020 01:30:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278260#M4919</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2020-09-09T01:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278261#M4920</link>
      <description>This works if it is what you are after.&lt;BR /&gt;

&lt;PRE&gt;n = 5

FOR i = 1 to n step 1
	x = 1
	If i = 3 then
		x = 5
	endif

	text2	i,	0,	x
next i
&lt;/PRE&gt;

&lt;BR /&gt;
Barry.</description>
      <pubDate>Wed, 09 Sep 2020 01:47:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278261#M4920</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2020-09-09T01:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278262#M4921</link>
      <description>&lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;X&lt;E&gt;&lt;/E&gt; is some previously defined value, external to the loop, it cannot be statically defined here.</description>
      <pubDate>Wed, 09 Sep 2020 01:56:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278262#M4921</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2020-09-09T01:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278263#M4922</link>
      <description>a few minor things:&lt;BR /&gt;
1. you can do the if statement in one line without the "endif". looks better and fewer lines of code.&lt;BR /&gt;
2. don't need the "step 1" as that is assumed unless otherwise defined&lt;BR /&gt;
&lt;BR /&gt;
so it should read:&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;n = 5
for i = 1 to n
	x = 1
	If i = 3 then x = 5
	text2	i,	0,	x
next i
&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Sep 2020 02:02:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278263#M4922</guid>
      <dc:creator>Kristian Bursell</dc:creator>
      <dc:date>2020-09-09T02:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278264#M4923</link>
      <description>looking back at your original post, it is as Barry said, just move the "x = 1" into the loop before the "if... x = 5".&lt;BR /&gt;
that way its reinstating the x = 1 for each value, and it only get overwritten when the if statement is true.</description>
      <pubDate>Wed, 09 Sep 2020 02:08:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278264#M4923</guid>
      <dc:creator>Kristian Bursell</dc:creator>
      <dc:date>2020-09-09T02:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278265#M4924</link>
      <description>Start of the script:
&lt;PRE&gt;d = B - gs_fw_lower - gs_fw_upper - 2 * gs_int_fw				!Louvre space
IF louvre_over &amp;lt;= 0 then							!If NO louvre overlap	
		n = int(d /(gs_louvre_width - louvre_over))
		dp = gs_louvre_width - louvre_over
	ELSE
		dp = gs_louvre_thk / ( cos ( atn ( ( gs_louvre_width - louvre_over) / gs_louvre_thk) ) )
		n = int(d / dp) + 1
endIF&lt;/PRE&gt;

&lt;BR /&gt;
The loop (for one set of conditionals):
&lt;PRE&gt;FOR i=1 to n

	...

	IF Louvred_sealside = "Both" then
		IF i = 1 | i = n then
			gs_louvre_opening_angle = gs_louvre_opening_max
			gs_louvre_width = sqr((d - (dp * (n - 1) + Louvre_over))^2 - (gs_louvre_thk)^2 ) + Louvre_over
		endIF
	endIF

	...

	cprism_ louvtopmat, louvbotmat, louvsidemat,
		5, gs_louvre_thk,
		-a / 2 + gs_fw_side_right + gs_int_fw,	-(gs_louvre_width) / 2,	_status,
		-a / 2 + gs_fw_side_right + gs_int_fw,	 (gs_louvre_width) / 2,	_status,
		 a / 2 - gs_fw_side_left - gs_int_fw,	 (gs_louvre_width) / 2,	_status,
		 a / 2 - gs_fw_side_left - gs_int_fw,	-(gs_louvre_width) / 2,	_status,
		-a / 2 + gs_fw_side_right + gs_int_fw,	-(gs_louvre_width) / 2,	-1

	...

next i&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Sep 2020 03:48:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278265#M4924</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2020-09-09T03:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278266#M4925</link>
      <description>if it's forbidden to repeat x=1 or use new parameter, n=5 like this:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;FOR i = 1 to n step 1
	If i = 3 then x = 5 then
	text2	y,	0,	x
	x=1
	endif
	text2	y,	0,	x
next i&lt;/PRE&gt;

maybe if you know precisely when it occurs just exclude from the loop? (though it looks awful)&lt;BR /&gt;
FOR i=1 to 2 ...&lt;BR /&gt;
if i=3 then ...&lt;BR /&gt;
FOR i=4 to n ...</description>
      <pubDate>Wed, 09 Sep 2020 07:17:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278266#M4925</guid>
      <dc:creator>A_ Smith</dc:creator>
      <dc:date>2020-09-09T07:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278267#M4926</link>
      <description>&lt;BLOCKQUOTE&gt;A. wrote:&lt;BR /&gt;
maybe if you know precisely when it occurs just exclude from the loop? (though it looks awful)&lt;BR /&gt;
FOR i=1 to 2 ...&lt;BR /&gt;
if i=3 then ...&lt;BR /&gt;
FOR i=4 to n ...
&lt;/BLOCKQUOTE&gt;

&lt;BR /&gt;
Doing so would basically double the script length... Easier to just populate a half dozen new variables to my list.</description>
      <pubDate>Wed, 09 Sep 2020 07:43:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278267#M4926</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2020-09-09T07:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278268#M4927</link>
      <description>&lt;BLOCKQUOTE&gt;Lingwisyer wrote:&lt;BR /&gt;
...parameter &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;X=A&lt;E&gt;&lt;/E&gt;, where &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;A&lt;E&gt;&lt;/E&gt; is some previously defined value, is it possible to pick out when &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;i=G then X=B&lt;E&gt;&lt;/E&gt; without needing to save &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;A&lt;E&gt;&lt;/E&gt; to a new parameter so that for other steps the original value is still utilised?
&lt;/BLOCKQUOTE&gt;

You just said it:
&lt;PRE&gt;if i = G then X = B else X = A&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Sep 2020 08:01:50 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278268#M4927</guid>
      <dc:creator>Peter Baksa</dc:creator>
      <dc:date>2020-09-09T08:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278269#M4928</link>
      <description>&lt;BLOCKQUOTE&gt;Peter wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;Lingwisyer wrote:&lt;BR /&gt;
...parameter &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;X=A&lt;E&gt;&lt;/E&gt;, where &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;A&lt;E&gt;&lt;/E&gt; is some previously defined value, is it possible to pick out when &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;i=G then X=B&lt;E&gt;&lt;/E&gt; without needing to save &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;A&lt;E&gt;&lt;/E&gt; to a new parameter so that for other steps the original value is still utilised?
&lt;/BLOCKQUOTE&gt;

You just said it:
&lt;PRE&gt;if i = G then X = B else X = A&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;BR /&gt;
Was hoping there would be a way that did not involve rewriting a dozen macros to use a dependent variable rather than the independent, and by the sounds of it, there is not so I will be needing to rewrite them at some point.&lt;BR /&gt;
&lt;BR /&gt;

&lt;PRE&gt;C = X
A = X

...

if i = G then C = B else C = A

...

*replace X with C in all dependent macros*&lt;/PRE&gt;

&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sorry for looking for a lazy way out,&lt;BR /&gt;
Ling.</description>
      <pubDate>Wed, 09 Sep 2020 08:18:43 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278269#M4928</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2020-09-09T08:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Parameter Reset</title>
      <link>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278270#M4929</link>
      <description>In parameter calls you can assign variables to parameters:
&lt;PRE&gt;call "macro" parameters A = something, ....&lt;/PRE&gt;
The subsequent calls from "macro" will use the value of &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;something&lt;E&gt;&lt;/E&gt;.&lt;BR /&gt;
If you don't want to write each parameter in the call, write just the modified ones:
&lt;PRE&gt;call "macro" parameters all, A = something&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Sep 2020 11:54:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Loop-Parameter-Reset/m-p/278270#M4929</guid>
      <dc:creator>Peter Baksa</dc:creator>
      <dc:date>2020-09-09T11:54:40Z</dc:date>
    </item>
  </channel>
</rss>

