<?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: Can two words be joined into a variable name? in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587030#M6286</link>
    <description>&lt;P&gt;Wow that is a good idea! DIM could be the way to go, I will see how I go coding, clean scripts coming up. Thank you so much Ling! Matt&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2024 02:09:39 GMT</pubDate>
    <dc:creator>GDL Enthusiast</dc:creator>
    <dc:date>2024-02-07T02:09:39Z</dc:date>
    <item>
      <title>Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/586781#M6270</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am wondering if it is possible to change the variable name on the fly, e.g when calling from a Subroutine, having the variable name part1+part2 merged together. An example would be a variable called Var_A where the prefix is added to the suffix, like Len = "Var"+"_A".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This would be great as it would allow a single subroutine to have its parameters changed easily, from _A to _C etc, especially when there are quite a few options variables and keep the code small. Is this possible or is there a better way of making a simple repeating subroutine with different variable inputs?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a code example in 2D Script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;option1 = 1
option2 = 1
option3 = 1

Var_A = 0.010
Var_B = 0.015
Var_C = 0.020

IF option1 = 1 THEN 
Suffix = "_A"
Len = "Var"+Suffix
Offset = 0.01
Gosub "CircleTest":
ENDIF

IF option2 = 1 THEN 
Suffix = "_B"
Len = "Var"+Suffix
Gosub "CircleTest":
ENDIF

IF option3 = 1 THEN 
Suffix = "_C"
Len = "Var"+Suffix
Gosub "CircleTest":
ENDIF

END

!*************************************
"CircleTest":              !Gosub Reference
Circle2 0,0,Len
RETURN&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Ideally this should return three circles, but it comes up with an error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to string together the suffix to a common prefix?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks, Matt&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 11:21:27 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/586781#M6270</guid>
      <dc:creator>GDL Enthusiast</dc:creator>
      <dc:date>2024-09-26T11:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/586789#M6271</link>
      <description>&lt;P&gt;No you can not change variable names, there should be no need to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All you need in this case is ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IF option1 = 1 THEN 
Len = 0.010
Offset = 0.01
Gosub "CircleTest":
ENDIF

IF option2 = 1 THEN 
Len = 0.015
Gosub "CircleTest":
ENDIF

IF option3 = 1 THEN 
Len = 0.020
Gosub "CircleTest":
ENDIF&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't quite get what you are trying to do with 'option_1', 'option_2' &amp;amp; 'option_3' parameters, unless they are 3 separate boolean (on/off0 parameters.&lt;/P&gt;
&lt;P&gt;So you could potentially have all 3 circles on at the same time.&lt;/P&gt;
&lt;P&gt;If you simply want a choice of option 1, 2 or 3, then create a integer parameter called 'Option' (without the quotes) and give it a VALUES list in the parameter script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VALUES "Options" 1, 2, 3&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you will be able to choose only one of the circles at any one time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 03:27:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/586789#M6271</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2024-02-06T03:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/586793#M6272</link>
      <description>&lt;P&gt;Hi Barry,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much for responding! &lt;SPAN&gt;I am trying to improve my coding skills. I see experts creating objects that are very concise in code, using subroutines. It seems pretty neat to be able to code so cleanly. I wondered if I could do it with changing variable names dynamically.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That is my answer "No you can not change variable names". Thank you again Barry and all the best, Matt&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 01:31:32 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/586793#M6272</guid>
      <dc:creator>GDL Enthusiast</dc:creator>
      <dc:date>2024-02-06T01:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/586796#M6273</link>
      <description>&lt;P&gt;The question is, why is there a need to change the variable name? In your example, it is redundant, hence Barry's answer. Does it not achieve what you are wanting? Is there something else you are trying to achieve?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ling.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 01:49:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/586796#M6273</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2024-02-06T01:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587012#M6283</link>
      <description>&lt;P&gt;Hi Ling,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for responding, I have seen some of your work and you are a true GDL coding artist! It would a dream to have your and Barry's level of coding skills.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;My thought stemmed from reading AC GDL objects and how clean the script was written. I have found what would take me 50 lines of code, experts could write in 20 lines. Much neater and cleaner to follow. So my thinking became, how can I, without going back to university to get a programming degree, make my script concise and clean. Along those lines, I wondered if I could somehow reuse Subroutines multiple times, instead of writing the same repeating code but with variations in the variable names. An example of the logic being:&lt;BR /&gt;&lt;BR /&gt;ValueListParameter 1 to 20, each with say 20 variables A to T. For that I code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IF ValueListParameter1=1 THEN
Len_ = 0.2
Ht_=0.33
Wdt_A=25

!...etc
Gosub "Create Object:"
ENDIF

...
IF ValueListParameter20=1 THEN
Len_ = 0.4
Ht_=1.33
Wdt_=58

!...etc
Gosub "Create Object:"
ENDIF
END
***********
"Create Object":
Len = Len_ 
Ht = Ht_ 
Wdt = Wdt_

!...etc
RETURN&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT size="3"&gt;The above 20 variables have suffixes A through to T say with unique values. In the Subroutine, if I could just change the variable suffix based upon the Gosub. Then the variables could all be stored cleanly at the start of the scipt, ready to be called and more easily managed.&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT size="3"&gt;If I could write something like this:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;!List of Variable Values to lookup:
Len_A = 0.2
Len_B=0.33
...
Len_T=0.43
Ht_A=58
...
Ht_T=58
Wdt_A=22
...
Wdt_T=32
!...etc

IF ValueListParameter1=1 THEN 
Suffix="A"
Gosub "Create Object":
ENDIF

...
IF ValueListParameter20=1 THEN 
Suffix="T"
Gosub "Create Object":
ENDIF
END

***********
"Create Object":
Len = "Len_" + Suffix 
Ht = "Ht_" + Suffix 
Wdt = "Wdt_" + Suffix 
!...etc
RETURN&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome any and all thoughts and many thanks, Matt&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2024 00:33:56 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587012#M6283</guid>
      <dc:creator>GDL Enthusiast</dc:creator>
      <dc:date>2024-02-11T00:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587023#M6285</link>
      <description>&lt;LI-CODE lang="markup"&gt;...
Len_ = Len_A
goSUB
...
Len_ = Len_B
goSUB
...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pretty sure what you were trying turns your parameter into a text type so that probably explains why it fails.&lt;BR /&gt;&lt;BR /&gt;You could also play with matrices.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DIM Len[]
Len[1] = 0.2
Len[2] = 0.33
...
Suffix = 1
goSUB
...
CIRCLE2 = 0, 0, Len[Suffix]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ling.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 01:33:19 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587023#M6285</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2024-02-07T01:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587030#M6286</link>
      <description>&lt;P&gt;Wow that is a good idea! DIM could be the way to go, I will see how I go coding, clean scripts coming up. Thank you so much Ling! Matt&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 02:09:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587030#M6286</guid>
      <dc:creator>GDL Enthusiast</dc:creator>
      <dc:date>2024-02-07T02:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587046#M6287</link>
      <description>&lt;P&gt;If you really wanted to, you could merge your Length (x), Width (y) and Height (z) parameters into a single two dimensional array.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 04:28:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587046#M6287</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2024-02-07T04:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587116#M6288</link>
      <description>&lt;P&gt;There are a few cases in which variables can be composed of several parts.&lt;BR /&gt;Example:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;_wall_scale = GLOB_SCALE
var = "Wall_" + STR(_wall_scale, 1, 0)

MATERIAL 1
GOSUB var

! ---------------------------- E N D ----------------------------------- !
! ---------------------------- E N D ----------------------------------- !

END  ! -- END -- END -- END -- END -- END -- END -- END -- END -- END -- !

! ---------------------------- E N D ----------------------------------- !
! ---------------------------- E N D ----------------------------------- !

"Wall_200":
	BLOCK 1, 1, 1
RETURN

! ---------------------------------------------------------------------- !
! ---------------------------------------------------------------------- !

"Wall_100":
	BLOCK 1, 2, 3
RETURN

! ---------------------------------------------------------------------- !
! ---------------------------------------------------------------------- !

"Wall_50":
	BLOCK 1, 4, 9
RETURN

! ---------------------------------------------------------------------- !
! ---------------------------------------------------------------------- !&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 07 Feb 2024 11:53:21 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587116#M6288</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2024-02-07T11:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587236#M6289</link>
      <description>&lt;P&gt;The difference is that GOSUB is expecting a&amp;nbsp;&lt;EM&gt;text&lt;/EM&gt; &lt;EM&gt;string&lt;/EM&gt;, which is what &lt;EM&gt;var&amp;nbsp;&lt;/EM&gt;is being defined as&lt;EM&gt;,&lt;/EM&gt; whilst&amp;nbsp;CIRCLE2 is expecting a&amp;nbsp;&lt;EM&gt;numeric string&amp;nbsp;&lt;/EM&gt;or&amp;nbsp;&lt;EM&gt;numberic parameter&lt;/EM&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 03:42:50 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587236#M6289</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2024-02-08T03:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587297#M6290</link>
      <description>&lt;P&gt;You can even use:&lt;BR /&gt;GOSUB 1000 + GLOB_SCALE&lt;BR /&gt;END&lt;BR /&gt;1050:&lt;BR /&gt;RETURN&lt;/P&gt;
&lt;P&gt;I think the difference is, that with CIRCLE2 there should be the Variable name composed with different parts, while in my examples the Value of the variables are composed of different parts. &lt;BR /&gt;I am sorry for the confusion.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 09:20:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587297#M6290</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2024-02-08T09:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587302#M6291</link>
      <description>&lt;P&gt;But the original poster wanted to join two strings together to change the variable name, not the variable value.&lt;/P&gt;
&lt;P&gt;So I think this is going a bit off topic, although it is good to know these techniques.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 09:30:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587302#M6291</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2024-02-08T09:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can two words be joined into a variable name?</title>
      <link>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587316#M6292</link>
      <description>&lt;P&gt;There are actually also situations in which the variable name can consist of compound parts; namely in cases in which a variable or a parameter name within a GDL command is to be used as a string with quotation marks.&lt;BR /&gt;Example:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;! Parameter 1 = qay_1, Parameter 2 = qay_2
UI_INFIELD "qay_" + STR(1, 1, 0), 20, 20, 100 , 20
UI_INFIELD "qay_" + STR(2, 1, 0), 20, 50, 100 , 20&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Feb 2024 11:26:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Can-two-words-be-joined-into-a-variable-name/m-p/587316#M6292</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2024-02-08T11:26:12Z</dc:date>
    </item>
  </channel>
</rss>

