<?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: Passing parameters to subroutines in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281251#M3364</link>
    <description>Ok. Thanks runxel.</description>
    <pubDate>Wed, 07 Jul 2021 05:20:05 GMT</pubDate>
    <dc:creator>dushyant</dc:creator>
    <dc:date>2021-07-07T05:20:05Z</dc:date>
    <item>
      <title>Passing parameters to subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281247#M3360</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi&lt;BR /&gt;&lt;BR /&gt;Is it possible to pass parameters to subroutines? This page talks about parameters, but I can't find the syntax: &lt;A href="https://gdl.graphisoft.com/gdl-style-guide/subroutines" target="_blank" rel="noopener"&gt;https://gdl.graphisoft.com/gdl-style-guide/subroutines&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also can subroutines call other subroutines?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:02:23 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281247#M3360</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2021-09-14T07:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281248#M3361</link>
      <description>Yes, you can pass parameters to subroutine and call another subroutine from previous. The script logic can be like that:&lt;BR /&gt;

&lt;PRE&gt;parameterName=1
GOSUB 'SUBROUTINE'
parameterName=2
GOSUB 'SUBROUTINE'
parameterName=3
GOSUB 'SUBROUTINE'

END

'SUBROUTINE':
IF parameterName=1 THEN GOSUB 'SUBROUTINE_1'
IF parameterName=2 THEN GOSUB 'SUBROUTINE_2'
IF parameterName=3 THEN GOSUB 'SUBROUTINE_3'
RETURN

'SUBROUTINE_1':
...
RETURN

'SUBROUTINE_2':
...
RETURN

'SUBROUTINE_3':
...
RETURN&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jul 2021 13:13:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281248#M3361</guid>
      <dc:creator>Podolsky</dc:creator>
      <dc:date>2021-07-06T13:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281249#M3362</link>
      <description>Thanks Podolsky. I don't see though the passing of parameters _to_ the subroutine. I understand what you did there &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;  but it's a bit odd to keep resetting the variable just so that the next call to the subroutine takes that value. I wish there was some way to pass custom params directly to subroutines, like you do with macros.</description>
      <pubDate>Tue, 06 Jul 2021 13:18:41 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281249#M3362</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2021-07-06T13:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281250#M3363</link>
      <description>This is simply not possible, and also, frankly, would not make any sense in a BASIC-derived language.&lt;BR /&gt;
&lt;BR /&gt;
See, GDL has no concept of scopes, so it makes no real sense to be able to pass any variables to a subroutine.&lt;BR /&gt;
A subroutine is &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;not&lt;/B&gt;&lt;E&gt;&lt;/E&gt; a function. It is basically the same as a GOTO, but you are able to RETURN. This alone doesn't make it a function as you might be used to as in other more modern scripting languages.&lt;BR /&gt;
&lt;BR /&gt;
The only thing that is &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;kind of&lt;E&gt;&lt;/E&gt; scoped in GDL is the transformation stack while using GROUPs.&lt;BR /&gt;
&lt;BR /&gt;
So, to recap: There are no functions, no scopes, and no variable passing in GDL.&lt;BR /&gt;
Instead every variable behaves as it would be global.&lt;BR /&gt;
Variables set in the Master script are even usable in every other script.&lt;BR /&gt;
&lt;BR /&gt;
Instead of the passing of a variable you need like podolsky has shown something that I call a "nasty caller".&lt;BR /&gt;

&lt;PRE&gt;if x = 1 then 
    nasty_caller = "foo"
else
    nasty_caller = "bar"
endif
gosub "Quz"
....
end
"Quz":
    ! do something with nasty_caller 
return
&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:23:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281250#M3363</guid>
      <dc:creator>runxel</dc:creator>
      <dc:date>2021-07-06T14:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to subroutines</title>
      <link>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281251#M3364</link>
      <description>Ok. Thanks runxel.</description>
      <pubDate>Wed, 07 Jul 2021 05:20:05 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Passing-parameters-to-subroutines/m-p/281251#M3364</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2021-07-07T05:20:05Z</dc:date>
    </item>
  </channel>
</rss>

