<?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: Using a List That Contains Variables in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8980598#M85072</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, a mixup&amp;nbsp; in the previous. VL-SYMBOL-VALUE works better...&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2019 08:43:58 GMT</pubDate>
    <dc:creator>martti.halminen</dc:creator>
    <dc:date>2019-08-22T08:43:58Z</dc:date>
    <item>
      <title>Using a List That Contains Variables</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8979810#M85069</link>
      <description>&lt;P&gt;Ok I want to set up some layers in a new drawing.&amp;nbsp; Depending on the number of layers chosen, the bottom layer will have a different name.&lt;/P&gt;&lt;P&gt;(Ex: for a 2 layer design the bottom layer will be "Lay_02", or a 4 layer the bottom layer will be "Lay_04".)&lt;/P&gt;&lt;P&gt;I can use strcat to create the name easily enough, but then I want to pass it to a function.&amp;nbsp; Since the name&amp;nbsp;could be different each time, I stored the name in a variable like "botLayName".&amp;nbsp; That gets added to a list that contains layer name and color.&lt;/P&gt;&lt;P&gt;Ex: ((topLayName "100") (secondLayName "32") (botLayName "3") )&lt;/P&gt;&lt;P&gt;I want to pass that list to a function and as it goes through the list it creates the layer and assigns it's color.&lt;/P&gt;&lt;P&gt;The trouble is, the layer name it gets is "botLayName" and not "Lay_04".&lt;/P&gt;&lt;P&gt;Is there a way to send the variables to a function and get the value from the variable and not just the variable name?&lt;/P&gt;&lt;P&gt;Maybe I'm doing it completely wrong in the first place, if there are better ideas, feel free to share.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 21:49:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8979810#M85069</guid>
      <dc:creator>mgorecki</dc:creator>
      <dc:date>2019-08-21T21:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using a List That Contains Variables</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8979895#M85070</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/70249"&gt;@mgorecki&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Ok I want to set up some layers in a new drawing.&amp;nbsp; Depending on the number of layers chosen, the bottom layer will have a different name.&lt;/P&gt;&lt;P&gt;(Ex: for a 2 layer design the bottom layer will be "Lay_02", or a 4 layer the bottom layer will be "Lay_04".)&lt;/P&gt;&lt;P&gt;I can use strcat to create the name easily enough, but then I want to pass it to a function.&amp;nbsp; Since the name&amp;nbsp;could be different each time, I stored the name in a variable like "botLayName".&amp;nbsp; That gets added to a list that contains layer name and color.&lt;/P&gt;&lt;P&gt;Ex: ((topLayName "100") (secondLayName "32") (botLayName "3") )&lt;/P&gt;&lt;P&gt;I want to pass that list to a function and as it goes through the list it creates the layer and assigns it's color.&lt;/P&gt;&lt;P&gt;The trouble is, the layer name it gets is "botLayName" and not "Lay_04".&lt;/P&gt;&lt;P&gt;Is there a way to send the variables to a function and get the value from the variable and not just the variable name?&lt;/P&gt;&lt;P&gt;Maybe I'm doing it completely wrong in the first place, if there are better ideas, feel free to share.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You need to construct the list using the list function and the cons function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(setq lyr_name "my-layer-name"&lt;BR /&gt;      lyr_col 100&lt;BR /&gt;)

(setq lst (cons (list lyr_name lyr_col) lst)); list ==&amp;gt; (("my-layer-name" 100))&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;Then pass the list to the functiion. In the function check if layer exists and if not make it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(foreach x lst
  (if (not (tblsearch "layer" (car x)))
    (command "-layer" "_M" (car x) "_C" (cadr x) "")
  );end_if
);end_foreach&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 22:56:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8979895#M85070</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2019-08-21T22:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using a List That Contains Variables</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8980595#M85071</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use the function VL-SYMBOL-NAME to find the value bound to the variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 08:39:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8980595#M85071</guid>
      <dc:creator>martti.halminen</dc:creator>
      <dc:date>2019-08-22T08:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using a List That Contains Variables</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8980598#M85072</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, a mixup&amp;nbsp; in the previous. VL-SYMBOL-VALUE works better...&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 08:43:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8980598#M85072</guid>
      <dc:creator>martti.halminen</dc:creator>
      <dc:date>2019-08-22T08:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using a List That Contains Variables</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8981483#M85073</link>
      <description>&lt;P&gt;Thank you very much.&amp;nbsp; That did the trick.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:19:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-a-list-that-contains-variables/m-p/8981483#M85073</guid>
      <dc:creator>mgorecki</dc:creator>
      <dc:date>2019-08-22T14:19:27Z</dc:date>
    </item>
  </channel>
</rss>

