<?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: Pass a string with quote marks to a lisp command in VB.NET in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3575354#M53902</link>
    <description>C# strAttValue = ("3/16" + "\"=1'-0\""); VB.NET strAttValue = ("3/16" &amp;amp; """=1'-0""") both return 3/16"=1'-0"</description>
    <pubDate>Mon, 13 Aug 2012 01:47:35 GMT</pubDate>
    <dc:creator>BrentBurgess1980</dc:creator>
    <dc:date>2012-08-13T01:47:35Z</dc:date>
    <item>
      <title>Pass a string with quote marks to a lisp command in VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3574682#M53901</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a string:&lt;/P&gt;&lt;P&gt;strAttValue = ("3/16""=1'-0""")&lt;/P&gt;&lt;P&gt;or alternatively I've tried:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;strAttValue = ("3/16" &amp;amp; Chr(34) &amp;amp; "=1'-0" &amp;amp; Chr(34))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that I would like to pass to a lisp with the format:&lt;/P&gt;&lt;P&gt;(defun lispTest ( strAttValue / )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but when I do it errors with "Too many variables." The passing method is as follows:&lt;/P&gt;&lt;P&gt;acDoc.SendStringToExecute("(lispTest" &amp;amp; Chr(34) &amp;amp;&amp;nbsp;strAttValue &amp;amp; Chr(34) &amp;amp; " ) ", True, False, False)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I get rid of the quotes in the original string it works fine, but the quotes are needed. Does anyone know why this is? How can I make it work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really should use VB.NET or C# more often, these simple things kill me and I am sure it is something obvious! - Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2012 22:52:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3574682#M53901</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-10T22:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a string with quote marks to a lisp command in VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3575354#M53902</link>
      <description>C# strAttValue = ("3/16" + "\"=1'-0\""); VB.NET strAttValue = ("3/16" &amp;amp; """=1'-0""") both return 3/16"=1'-0"</description>
      <pubDate>Mon, 13 Aug 2012 01:47:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3575354#M53902</guid>
      <dc:creator>BrentBurgess1980</dc:creator>
      <dc:date>2012-08-13T01:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a string with quote marks to a lisp command in VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3576482#M53903</link>
      <description>&lt;P&gt;EDIT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, the " symbol is the culprit. If I create:&lt;/P&gt;&lt;P&gt;strAttValue = ("3/16=1'-0")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it works fine, but I need the " symbol to be part of the string so I am stuck. Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use a (princ strAttValue) using ssomething like&amp;nbsp;strAttValue = ("3/16" &amp;amp; """=1'-0""")&lt;/P&gt;&lt;P&gt;I get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;bad argument type: FILE "=1'-0"&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2012 18:40:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3576482#M53903</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-13T18:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a string with quote marks to a lisp command in VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3576718#M53904</link>
      <description>&lt;P&gt;Every &lt;STRONG&gt;Chr(34)&lt;/STRONG&gt; have to be replaced with &lt;STRONG&gt;Chr(92) &amp;amp; Chr(34)&lt;/STRONG&gt; in order to passed to lisp.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:25:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3576718#M53904</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-08-13T20:25:09Z</dc:date>
    </item>
    <item>
      <title>Re : Pass a string with quote marks to a lisp command in VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3576788#M53905</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IMO, you'd rather use the Application.Invoke() (A2011 or later), or P/Invoke acedInvoke() (for prior versions) with which you can invoke a LISP function and get its return value.&lt;/P&gt;&lt;P&gt;Your LISP function have to be registered with vl-acad-defun or be prefixed with c:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a little example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LISP function&lt;/P&gt;&lt;PRE&gt;(defun lispTest (strArg)
  (princ (strcat "\nstrArg: " strArg "\n"))
  strArg
)
(vl-acad-defun 'lispTest)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C# code with Application.Invoke():&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("Foo")]        &lt;BR /&gt;        public void Foo()
        {
            ResultBuffer args = new ResultBuffer(
                new TypedValue((int)LispDataType.Text, "lispTest"),
                new TypedValue((int)LispDataType.Text, "3/16\"=1'-0\"\""));
            ResultBuffer retVal = Application.Invoke(args);
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(
                "\nretVal:" + retVal.AsArray()[0].Value);
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C# code with P/Invoke acedInvoke:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [System.Security.SuppressUnmanagedCodeSecurity]
        [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
        extern static private int acedInvoke(IntPtr rbIn, out IntPtr rbOut);

        public static ResultBuffer InvokeLisp(ResultBuffer args)
        {
            IntPtr rb = IntPtr.Zero;
            int stat = acedInvoke(args.UnmanagedObject, out rb);
            if (stat == (int)PromptStatus.OK &amp;amp;&amp;amp; rb != IntPtr.Zero)
                return (ResultBuffer)DisposableWrapper.Create(typeof(ResultBuffer), rb, true);
            return null;
        }

        [CommandMethod("Bar")]
        public void Bar()
        {
            ResultBuffer args = new ResultBuffer(
                new TypedValue((int)LispDataType.Text, "lispTest"),
                new TypedValue((int)LispDataType.Text, "3/16\"=1'-0\"\""));
            ResultBuffer retVal = Application.Invoke(args);
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(
                "\nretVal:" + retVal.AsArray()[0].Value);
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2012 21:06:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/pass-a-string-with-quote-marks-to-a-lisp-command-in-vb-net/m-p/3576788#M53905</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2012-08-13T21:06:15Z</dc:date>
    </item>
  </channel>
</rss>

