<?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: Possible for the user to add to an array? in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/331922#M2659</link>
    <description>&lt;P&gt;Yes, that is possible.&lt;/P&gt;&lt;P&gt;But you need an UI, tho. You are right, the user can't change the dimension of the array later on. Teh reason behind this is that the programmer needs to be in control of their data structure – everything else would invoke hazard sooner or later for sure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="runxel_0-1646920043771.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/19581iDA1F270C46AB995E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="runxel_0-1646920043771.png" alt="runxel_0-1646920043771.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have an UI you could script the adding and deleting. E.g. the old room stamp had something you could reuse (at least the german one had this feature):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="runxel_1-1646920277240.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/19582i6FFC34186660C391/image-size/medium?v=v2&amp;amp;px=400" role="button" title="runxel_1-1646920277240.png" alt="runxel_1-1646920277240.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You have to tie a function to the buttons basically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, a completely different way I implemented in some of my objects, is to actually parse a string and populate the array afterwards.&lt;/P&gt;&lt;P&gt;The input could look like this "1,44, 6-17, 25, 3". A bit like printing pages from a PDF.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried something totally ridiculous: Overlaying an ui_infield (to have the accurat color represenation) by an ui_pict_pushcheckbutton.... but that does not really work.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Mar 2022 14:14:15 GMT</pubDate>
    <dc:creator>runxel</dc:creator>
    <dc:date>2022-03-10T14:14:15Z</dc:date>
    <item>
      <title>Possible for the user to add to an array?</title>
      <link>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/331913#M2658</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a 2D "person" object and I would like the clothes to be randomised using an array. I currently have it working as such:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;top_random = rnd(vardim1(top_colour))
pen top_colour[top_random]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The user is able to edit the current values of the array (to set the pens they want to randomise from) but I was wondering if there is any way that the user is able to add / remove lines of the array to reduce or increase potential pens as it is currently greyed out?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 11:29:02 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/331913#M2658</guid>
      <dc:creator>JGoode</dc:creator>
      <dc:date>2022-03-10T11:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Possible for the user to add to an array?</title>
      <link>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/331922#M2659</link>
      <description>&lt;P&gt;Yes, that is possible.&lt;/P&gt;&lt;P&gt;But you need an UI, tho. You are right, the user can't change the dimension of the array later on. Teh reason behind this is that the programmer needs to be in control of their data structure – everything else would invoke hazard sooner or later for sure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="runxel_0-1646920043771.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/19581iDA1F270C46AB995E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="runxel_0-1646920043771.png" alt="runxel_0-1646920043771.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have an UI you could script the adding and deleting. E.g. the old room stamp had something you could reuse (at least the german one had this feature):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="runxel_1-1646920277240.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/19582i6FFC34186660C391/image-size/medium?v=v2&amp;amp;px=400" role="button" title="runxel_1-1646920277240.png" alt="runxel_1-1646920277240.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You have to tie a function to the buttons basically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, a completely different way I implemented in some of my objects, is to actually parse a string and populate the array afterwards.&lt;/P&gt;&lt;P&gt;The input could look like this "1,44, 6-17, 25, 3". A bit like printing pages from a PDF.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried something totally ridiculous: Overlaying an ui_infield (to have the accurat color represenation) by an ui_pict_pushcheckbutton.... but that does not really work.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 14:14:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/331922#M2659</guid>
      <dc:creator>runxel</dc:creator>
      <dc:date>2022-03-10T14:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Possible for the user to add to an array?</title>
      <link>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/332014#M2660</link>
      <description>&lt;P&gt;Thanks for your help. I added in a way to add rows to the array using a boolean and it seems to work well. I was wondering if you knew of a way to then reduce the rows using a similar method. I had a look in the Zone Stamp as that has a way of adding and removing but I found it rather confusing to follow!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if (glob_modpar_name = "add_top") then
	if (add_top) then
		num_top = vardim1(top_colour) + 1
		top_colour[num_top] = 1
		add_top = 0
		parameters add_top=add_top
		parameters top_colour=top_colour
	endif
endif&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 11:00:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/332014#M2660</guid>
      <dc:creator>JGoode</dc:creator>
      <dc:date>2022-03-11T11:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: Possible for the user to add to an array?</title>
      <link>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/332022#M2661</link>
      <description>&lt;P&gt;Deleting rows is similar, but you'll need another temp structure.&lt;/P&gt;&lt;P&gt;Following your style:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;dim EMPTYARRAY[]
!...
if GLOB_MODPAR_NAME = "del_top" then
    if del_top then
        dim temp[]
        for i=1 to vardim1(top_colour)-1
            temp[i] = top_color[i]
        next i
        ! reset the array first
        top_colour = EMPTYARRAY
        top_colour = temp
        del_top = 0
        parameters \
            del_top = del_top,
            top_colour = top_colour
    endif
endif&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 12:38:19 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/332022#M2661</guid>
      <dc:creator>runxel</dc:creator>
      <dc:date>2022-03-11T12:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Possible for the user to add to an array?</title>
      <link>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/332024#M2662</link>
      <description>&lt;P&gt;You're a genius! Thank you so much for your help, that is working perfectly now.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 12:58:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Possible-for-the-user-to-add-to-an-array/m-p/332024#M2662</guid>
      <dc:creator>JGoode</dc:creator>
      <dc:date>2022-03-11T12:58:38Z</dc:date>
    </item>
  </channel>
</rss>

