<?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: Setting array dimensions with parameters in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282754#M3397</link>
    <description>&lt;BLOCKQUOTE&gt;Podolsky wrote:&lt;BR /&gt;
It depends on what you need your array. I'm using the method you describe when I have an array (let say coordinates of polygon) and I want to add a new node
&lt;/BLOCKQUOTE&gt;
I agree completely. You should be as efficient as possible in your code. Most of my arrays require the dynamic variation so that is the method I apply. If your application does not need to be dynamic like editing a polygon then perhaps it is overkill.</description>
    <pubDate>Mon, 12 Jul 2021 10:16:37 GMT</pubDate>
    <dc:creator>Kristian Bursell</dc:creator>
    <dc:date>2021-07-12T10:16:37Z</dc:date>
    <item>
      <title>Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282750#M3393</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi&lt;BR /&gt;&lt;BR /&gt;I'm trying to set an array's dimension by using a parameter value, like this:&lt;BR /&gt;
&lt;PRE&gt;num = 3 !will be set by the parameter

DIM myArray[num] &lt;/PRE&gt;
This gives an error as: &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;"Array dimensions must be positive numeric constants ..."&lt;BR /&gt;&lt;BR /&gt;It does work, of course, with: DIM myArray[3] , but I want this array-dimension to be based on a parameter.&lt;BR /&gt;&lt;BR /&gt;How to achieve this?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:01:07 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282750#M3393</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2021-09-14T07:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282751#M3394</link>
      <description>Archive it different way.&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;num=3

DIM myArray[]

FOR i=1 to num

myArray&lt;I&gt;=something

NEXT i
&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jul 2021 08:39:47 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282751#M3394</guid>
      <dc:creator>Podolsky</dc:creator>
      <dc:date>2021-07-12T08:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282752#M3395</link>
      <description>best practice is to build a local array and pass it to to the parameter array, and then also use/reference this local array (assuming master script) in other scripts instead of the parameter array as this means you don't have to wait for the parameter to update in the array for it to apply in the code because the local array already has the value from the master script which is run first.&lt;BR /&gt;
&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;num = 3

dim _myArray[]
for i = 1 to num
    if i &amp;gt; vardim1(myArray) then
        _myArray&lt;I&gt; = "put a default value here"
    else
        _myArray&lt;I&gt; = myArray&lt;I&gt;
    endif
next i
myArray = _myArray
parameters myArray = myArray
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jul 2021 09:28:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282752#M3395</guid>
      <dc:creator>Kristian Bursell</dc:creator>
      <dc:date>2021-07-12T09:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282753#M3396</link>
      <description>&lt;BLOCKQUOTE&gt;Kristian wrote:&lt;BR /&gt;
best practice is to build a local array and pass it to to the parameter array, and then also use/reference this local array (assuming master script) in other scripts instead of the parameter array as this means you don't have to wait for the parameter to update in the array for it to apply in the code because the local array already has the value from the master script which is run first.&lt;BR /&gt;
&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;num = 3

dim _myArray[]
for i = 1 to num
    if i &amp;gt; vardim1(myArray) then
        _myArray&lt;I&gt; = "put a default value here"
    else
        _myArray&lt;I&gt; = myArray&lt;I&gt;
    endif
next i
myArray = _myArray
parameters myArray = myArray
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

It depends on what you need your array. I'm using the method you describe when I have an array (let say coordinates of polygon) and I want to add a new node. Then if I have an array with three points coordinates, I'm passing their coordinates to temporary array, adding at the end additional dimension and coordinates of the new point.&lt;BR /&gt;
&lt;BR /&gt;
I also can say - I've found many GDL scripts (especially from ArchiCAD library) are very very big. They writing with 20-30 lines that potentially possible to write with 10. I don't know where is the secret in it - is it example of good programming Graphisoft is showing to us (well they are mathematicians, studied programming in university) - but somehow I have decided to develop different style trying to make scripts as short as possible. And also that script possible to read by human - without additional notes and explanations, so I'm paying extra attention to variable names.</description>
      <pubDate>Mon, 12 Jul 2021 10:09:08 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282753#M3396</guid>
      <dc:creator>Podolsky</dc:creator>
      <dc:date>2021-07-12T10:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282754#M3397</link>
      <description>&lt;BLOCKQUOTE&gt;Podolsky wrote:&lt;BR /&gt;
It depends on what you need your array. I'm using the method you describe when I have an array (let say coordinates of polygon) and I want to add a new node
&lt;/BLOCKQUOTE&gt;
I agree completely. You should be as efficient as possible in your code. Most of my arrays require the dynamic variation so that is the method I apply. If your application does not need to be dynamic like editing a polygon then perhaps it is overkill.</description>
      <pubDate>Mon, 12 Jul 2021 10:16:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282754#M3397</guid>
      <dc:creator>Kristian Bursell</dc:creator>
      <dc:date>2021-07-12T10:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282755#M3398</link>
      <description>Thanks, Podolsky &amp;amp; Kristian.&lt;BR /&gt;
&lt;BR /&gt;
Podolsky, yes, that looks like a way around it.&lt;BR /&gt;
&lt;BR /&gt;
How do you initialise a two-dimensional array as a blank? DIM myArray[][] ?</description>
      <pubDate>Mon, 12 Jul 2021 10:22:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282755#M3398</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2021-07-12T10:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282756#M3399</link>
      <description>&lt;BLOCKQUOTE&gt;dushyant wrote:&lt;BR /&gt;
Thanks, Podolsky &amp;amp; Kristian.&lt;BR /&gt;
&lt;BR /&gt;
Podolsky, yes, that looks like a way around it.&lt;BR /&gt;
&lt;BR /&gt;
How do you initialise a two-dimensional array as a blank? DIM myArray[][] ?
&lt;/BLOCKQUOTE&gt;

yes</description>
      <pubDate>Mon, 12 Jul 2021 10:39:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282756#M3399</guid>
      <dc:creator>Podolsky</dc:creator>
      <dc:date>2021-07-12T10:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282757#M3400</link>
      <description>Thanks!</description>
      <pubDate>Mon, 12 Jul 2021 14:09:47 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282757#M3400</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2021-07-12T14:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Setting array dimensions with parameters</title>
      <link>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282758#M3401</link>
      <description>Once I had similar issue - &lt;A href="https://archicad-talk.graphisoft.com/viewtopic.php?p=321896#p321896" target="_blank"&gt;that's the reply&lt;/A&gt; of Peter Baksa</description>
      <pubDate>Tue, 13 Jul 2021 08:32:50 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Setting-array-dimensions-with-parameters/m-p/282758#M3401</guid>
      <dc:creator>A_ Smith</dc:creator>
      <dc:date>2021-07-13T08:32:50Z</dc:date>
    </item>
  </channel>
</rss>

