<?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: Question about Arrays &amp;amp; Subroutines in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276370#M4872</link>
    <description>From the book&lt;B&gt; GDL Handbook, by Andrew Watson&lt;/B&gt;, 3.5.Scope, pages 36-37&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;Array variables have some interesting characteristics when it comes to scope. You must define an array before you can use it, which stands to reason. You can define an array variable in a sub-routine (we’ll discuss sub-routines later) but it’s best to define arrays in the main script. If you define an array variable in a sub-routine and then try to use it in the main script, error messages will pop up when you try to save the object.  &lt;E&gt;&lt;/E&gt;&lt;BR /&gt;
&lt;BR /&gt;
and later:&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;The variable must be declared at a point in the script that comes both physically and logically ahead of the point at which it is used. &lt;E&gt;&lt;/E&gt;</description>
    <pubDate>Tue, 06 Oct 2020 11:55:01 GMT</pubDate>
    <dc:creator>leceta</dc:creator>
    <dc:date>2020-10-06T11:55:01Z</dc:date>
    <item>
      <title>Question about Arrays &amp; Subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276367#M4869</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi there,&lt;BR /&gt;&lt;BR /&gt;I would like to ask why the creation of arrays in a sub-routine in Parameter script as in the following example is generating an error ("Incompatible array dimensions")&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;
some script

if condition is met then
	gosub 001

	_tempArray = _origArray		!&amp;lt;--both arrays are one dimension
endif

some script

end

001:

dim _tempArray

return

&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 26 Sep 2022 20:45:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276367#M4869</guid>
      <dc:creator>Nader Belal</dc:creator>
      <dc:date>2022-09-26T20:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Question about Arrays &amp; Subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276368#M4870</link>
      <description>In my experience it happens, that arrays defined in a subroutine where not recognized in parts of scripts that are above the subroutine (in the text order).&lt;BR /&gt;
Example:
&lt;PRE&gt;gosub 100
_newVALUE = _tempArray[1]		
end
100:
dim _tempArray[]
_tempArray[1] = 2
return
&lt;/PRE&gt;
But if you change this into this, it works:
&lt;PRE&gt;gosub 100
gosub 200
end
100:
dim _tempArray[]
_tempArray[1] = 2
return

200:
_newVALUE = _tempArray[1]	
return&lt;/PRE&gt;
This is a weird thing, but I think, it is a bug.</description>
      <pubDate>Wed, 02 Sep 2020 13:35:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276368#M4870</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2020-09-02T13:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Question about Arrays &amp; Subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276369#M4871</link>
      <description>@Joachim Suehlo&lt;BR /&gt;
&lt;BR /&gt;
Thank you a lot.</description>
      <pubDate>Wed, 02 Sep 2020 16:29:45 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276369#M4871</guid>
      <dc:creator>Nader Belal</dc:creator>
      <dc:date>2020-09-02T16:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Question about Arrays &amp; Subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276370#M4872</link>
      <description>From the book&lt;B&gt; GDL Handbook, by Andrew Watson&lt;/B&gt;, 3.5.Scope, pages 36-37&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;Array variables have some interesting characteristics when it comes to scope. You must define an array before you can use it, which stands to reason. You can define an array variable in a sub-routine (we’ll discuss sub-routines later) but it’s best to define arrays in the main script. If you define an array variable in a sub-routine and then try to use it in the main script, error messages will pop up when you try to save the object.  &lt;E&gt;&lt;/E&gt;&lt;BR /&gt;
&lt;BR /&gt;
and later:&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;The variable must be declared at a point in the script that comes both physically and logically ahead of the point at which it is used. &lt;E&gt;&lt;/E&gt;</description>
      <pubDate>Tue, 06 Oct 2020 11:55:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276370#M4872</guid>
      <dc:creator>leceta</dc:creator>
      <dc:date>2020-10-06T11:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Question about Arrays &amp; Subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276371#M4873</link>
      <description>&lt;BLOCKQUOTE&gt;Joachim wrote:&lt;BR /&gt;
This is a weird thing, but I think, it is a bug.
&lt;/BLOCKQUOTE&gt;

This isn't a bug, it's a limitation. The order of statements can depend on parameters, it is only known at run-time. Variables mustn't change their types during run, the best the interpreter can do is check the code line-by-line (there are simple cases when the order of execution is evident, but it can get complicated very easily). If it didn't do this check, it would be possible to get error messages only by some parameter states, which would make them very hard to detect and understand.</description>
      <pubDate>Tue, 06 Oct 2020 15:07:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Question-about-Arrays-amp-Subroutines/m-p/276371#M4873</guid>
      <dc:creator>Peter Baksa</dc:creator>
      <dc:date>2020-10-06T15:07:44Z</dc:date>
    </item>
  </channel>
</rss>

