<?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 Defining an array based on an integer parameter in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Defining-an-array-based-on-an-integer-parameter/m-p/355430#M1214</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to define an array by an integer. I want my array to have an equal amount of fields as an integer. I want to be able to use the array fields to define positions of elements so they need to hold the values while more are added or removed based on the integer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I have currently, however it locks the value to 0 as I would expect. I'm just not sure how to achieve what I'm after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DIM num_position_x2[]
DIM num_position_y2[]
if (glob_modpar_name = "num_steps") or (glob_modpar_name = "total_distance") then

	for i=1 to num_steps2
		num_position_x2[i] = 0
		num_position_y2[i] = 0
	next i
	parameters num_position_x2=num_position_x2	
	parameters num_position_y2=num_position_y2
endif&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2022 20:41:10 GMT</pubDate>
    <dc:creator>JGoode</dc:creator>
    <dc:date>2022-09-26T20:41:10Z</dc:date>
    <item>
      <title>Defining an array based on an integer parameter</title>
      <link>https://community.graphisoft.com/t5/GDL/Defining-an-array-based-on-an-integer-parameter/m-p/355430#M1214</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to define an array by an integer. I want my array to have an equal amount of fields as an integer. I want to be able to use the array fields to define positions of elements so they need to hold the values while more are added or removed based on the integer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I have currently, however it locks the value to 0 as I would expect. I'm just not sure how to achieve what I'm after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DIM num_position_x2[]
DIM num_position_y2[]
if (glob_modpar_name = "num_steps") or (glob_modpar_name = "total_distance") then

	for i=1 to num_steps2
		num_position_x2[i] = 0
		num_position_y2[i] = 0
	next i
	parameters num_position_x2=num_position_x2	
	parameters num_position_y2=num_position_y2
endif&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 20:41:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Defining-an-array-based-on-an-integer-parameter/m-p/355430#M1214</guid>
      <dc:creator>JGoode</dc:creator>
      <dc:date>2022-09-26T20:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Defining an array based on an integer parameter</title>
      <link>https://community.graphisoft.com/t5/GDL/Defining-an-array-based-on-an-integer-parameter/m-p/355441#M1215</link>
      <description>&lt;P&gt;You're on the right track!&lt;/P&gt;&lt;P&gt;You will need to shadow the parameters. I have prepared a small but working example, which can be easily extended to suit all your needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;dim EMPTYARRAY[]

if GLOB_MODPAR_NAME = "n_steps" then
	if n_steps_shadow &amp;lt; n_steps then
		! We have more steps than before
		for i=(n_steps_shadow+1) to n_steps
			! init those values
			x_pos[i] = 0.0
		next i
	else
		! Less steps then before
		dim _newx[]
		for i=1 to n_steps
			_newx[i] = x_pos[i]
		next i
		x_pos = EMPTYARRAY
		x_pos = _newx
	endif
	n_steps_shadow = n_steps
endif

parameters \
	x_pos = x_pos,
	n_steps_shadow = n_steps_shadow&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 14:43:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Defining-an-array-based-on-an-integer-parameter/m-p/355441#M1215</guid>
      <dc:creator>runxel</dc:creator>
      <dc:date>2022-09-08T14:43:36Z</dc:date>
    </item>
  </channel>
</rss>

