<?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: Remove (text) from a List in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456757#M20217</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14461688"&gt;@DGCSCAD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I 'm taking a string and cross-checking for a match in a comma delimited text file. The only common denominator between 1500 different strings is their "type", which is always the 2nd element in the returned list after matching the string. Some of the returned lists have (text), which throws off my nth count for those lists, but other than that they are consistent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found a solution using an if statement (see below) which accounts for each situation and is consistent throughout, but I'd still like to see how to resolve the original predicament. For science purposes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--- &amp;gt;%&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Sorry, but it sounds like you may be making a tempest in a teacup.&amp;nbsp; See my post on &lt;A href="https://www.theswamp.org/index.php?topic=58149.msg613580#msg613580" target="_self"&gt;Self-commenting code.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;-i.e. can't you just assign names to those positions and not really worry about "contents"?&lt;/P&gt;&lt;P&gt;-e.g.&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;( (lambda ( / one-half
              numer denom make )
    (set 'numer car)
    (set 'denom cdr)
    (set 'make cons)
    (setq one-half (make 1 2))
    (princ (strcat "\nNumerator: " (itoa (numer one-half))))
    (princ (strcat "\nDenominator: " (itoa (denom one-half))))

    (if (eq (type (numer one-half)) 'STRING)
      "Our fraction is broken!"
      )

    (princ)
    )
 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Dec 2023 20:48:12 GMT</pubDate>
    <dc:creator>john.kaulB9QW2</dc:creator>
    <dc:date>2023-12-21T20:48:12Z</dc:date>
    <item>
      <title>Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456087#M20208</link>
      <description>&lt;P&gt;How would I remove (CENTER) from this list?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List:&lt;/P&gt;&lt;P&gt;(CT5625062-1 (CENTER) NO NO TUBE)&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 15:42:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456087#M20208</guid>
      <dc:creator>DGCSCAD</dc:creator>
      <dc:date>2023-12-21T15:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456124#M20209</link>
      <description>&lt;P&gt;If it's '&lt;SPAN&gt;("CT5625062-1 (CENTER) NO NO TUBE")&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;use&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG style="font-family: inherit;"&gt;vl-string-subst&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 15:54:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456124#M20209</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2023-12-21T15:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456130#M20210</link>
      <description>&lt;P&gt;Here you have one option that checks all text entities inside list&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(SETQ
	LST '
		(
			"CT5625062-1 (CENTER) NO NO TUBE" 
			"CT5625062-1 (CENTER) NO NO TUBE"
			"CT5625062-1 (CENTER) NO NO TUBE"
		)
	LST (MAPCAR '(lambda (x)(vl-string-subst "" " (CENTER)" x 0)) lst)
)
; result  ("CT5625062-1 NO NO TUBE" "CT5625062-1 NO NO TUBE" "CT5625062-1 NO NO TUBE")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 21 Dec 2023 15:55:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456130#M20210</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2023-12-21T15:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456207#M20211</link>
      <description>&lt;P&gt;Command: (vl-remove '(CENTER) '(CT5625062-1 (CENTER) NO NO TUBE))&lt;BR /&gt;(CT5625062-1 NO NO TUBE)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Didn't I make a beginner programming challenge for something like this at TheSwamp as well?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 16:17:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456207#M20211</guid>
      <dc:creator>john.kaulB9QW2</dc:creator>
      <dc:date>2023-12-21T16:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456251#M20212</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12045724"&gt;@john.kaulB9QW2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Command: (vl-remove '(CENTER) '(CT5625062-1 (CENTER) NO NO TUBE))&lt;BR /&gt;(CT5625062-1 NO NO TUBE)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Didn't I make a beginner programming challenge for something like this at TheSwamp as well?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I think you may have, many moons ago. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the replies. I should have mentioned that the (CENTER) changes to other characters and is variable, but there's always alphabetical characters within the ( and ).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that makes sense?&lt;/P&gt;&lt;P&gt;I'd need to use wildcards (*).&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 16:32:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456251#M20212</guid>
      <dc:creator>DGCSCAD</dc:creator>
      <dc:date>2023-12-21T16:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456301#M20213</link>
      <description>&lt;P&gt;'variable', 'wildcards', 'nested list' are red-flags that you should be asking a different question. What are you doing? Why are you removing items from a list (can you ignore instead)?&amp;nbsp; -i.e. I have tried to demonstrate that more often than not you can typically get around "sorting" a list (because these types of operations are expensive); so that last question is/can be "what are you trying to do to each item in the list"?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 16:56:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456301#M20213</guid>
      <dc:creator>john.kaulB9QW2</dc:creator>
      <dc:date>2023-12-21T16:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456455#M20214</link>
      <description>&lt;P&gt;I 'm taking a string and cross-checking for a match in a comma delimited text file. The only common denominator between 1500 different strings is their "type", which is always the 2nd element in the returned list after matching the string. Some of the returned lists have (text), which throws off my nth count for those lists, but other than that they are consistent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found a solution using an if statement (see below) which accounts for each situation and is consistent throughout, but I'd still like to see how to resolve the original predicament. For science purposes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code snippet:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(findfile (setq TextFile "mytxtfile.txt"))
(setq SearchStr (strcat "Part1" ","))
(setq Opened (open TextFile "r"))
	(while (setq tmpLine (read-line Opened))
		(if (vl-string-search SearchStr tmpLine)
			(setq endlist tmpLine)
		)
	)
(close Opened)
(if (/= endlist nil)
	(progn
		(setq term_type1_list (read (strcat "(" (vl-string-translate "," " " endlist) ")")))
		(setq term_list1_lngth (length term_type1_list))
		(if (= term_list1_lngth 4)
			(setq term_type1 (nth 1 term_type1_list))
			(setq term_type1 (nth 2 term_type1_list))
		)
         )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 18:21:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456455#M20214</guid>
      <dc:creator>DGCSCAD</dc:creator>
      <dc:date>2023-12-21T18:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456487#M20215</link>
      <description>&lt;P&gt;&lt;STRONG&gt;(setq _list '(CT5625062-1 (CENTER) NO NO TUBE))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(vl-remove (cadr _list) _list)&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 18:39:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456487#M20215</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-12-21T18:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456528#M20216</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13423916"&gt;@komondormrex&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;STRONG&gt;(setq _list '(CT5625062-1 (CENTER) NO NO TUBE))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(vl-remove (cadr _list) _list)&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;As simple as that. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you komondormrex.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 18:55:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456528#M20216</guid>
      <dc:creator>DGCSCAD</dc:creator>
      <dc:date>2023-12-21T18:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456757#M20217</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14461688"&gt;@DGCSCAD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I 'm taking a string and cross-checking for a match in a comma delimited text file. The only common denominator between 1500 different strings is their "type", which is always the 2nd element in the returned list after matching the string. Some of the returned lists have (text), which throws off my nth count for those lists, but other than that they are consistent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found a solution using an if statement (see below) which accounts for each situation and is consistent throughout, but I'd still like to see how to resolve the original predicament. For science purposes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--- &amp;gt;%&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Sorry, but it sounds like you may be making a tempest in a teacup.&amp;nbsp; See my post on &lt;A href="https://www.theswamp.org/index.php?topic=58149.msg613580#msg613580" target="_self"&gt;Self-commenting code.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;-i.e. can't you just assign names to those positions and not really worry about "contents"?&lt;/P&gt;&lt;P&gt;-e.g.&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;( (lambda ( / one-half
              numer denom make )
    (set 'numer car)
    (set 'denom cdr)
    (set 'make cons)
    (setq one-half (make 1 2))
    (princ (strcat "\nNumerator: " (itoa (numer one-half))))
    (princ (strcat "\nDenominator: " (itoa (denom one-half))))

    (if (eq (type (numer one-half)) 'STRING)
      "Our fraction is broken!"
      )

    (princ)
    )
 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 20:48:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456757#M20217</guid>
      <dc:creator>john.kaulB9QW2</dc:creator>
      <dc:date>2023-12-21T20:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456790#M20218</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14461688"&gt;@DGCSCAD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;As simple as that.&amp;nbsp;&lt;SPAN&gt;....&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Another simple way to remove the second item, whatever it is, from any List:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;&lt;STRONG&gt;(cons (car TheList) (cddr TheList))&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#333333"&gt;That has the advantage, if the situation arises, that if that second item is one of &lt;EM&gt;more than one&lt;/EM&gt; occurrence of the same thing in the list, this will remove only the one in the second position, whereas&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (vl-remove)&lt;/FONT&gt; &lt;/STRONG&gt;&lt;/FONT&gt;will remove &lt;EM&gt;all&lt;/EM&gt; occurrences of the same entry.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 21:06:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12456790#M20218</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-12-21T21:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12459839#M20219</link>
      <description>&lt;P&gt;Another re message 5 always "(text)".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq str "CT5625062-1 (CENTER) NO NO TUBE")
(setq pos1 (vl-string-search "(" str))
(setq pos2 (vl-string-search ")" str))
(setq str (strcat (substr str 1 (- pos1 1)) (substr str (+ pos2 2))))

"CT5625062-1 NO NO TUBE"&lt;/LI-CODE&gt;&lt;P&gt;Another&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Dec 2023 00:32:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12459839#M20219</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2023-12-24T00:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Remove (text) from a List</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12466311#M20220</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12045724"&gt;@john.kaulB9QW2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Sorry, but it sounds like you may be making a tempest in a teacup.&amp;nbsp; See my post on &lt;A href="https://www.theswamp.org/index.php?topic=58149.msg613580#msg613580" target="_self"&gt;Self-commenting code.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;-i.e. can't you just assign names to those positions and not really worry about "contents"?&lt;/P&gt;&lt;P&gt;-e.g.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;( (lambda ( / one-half
              numer denom make )
    (set 'numer car)
    (set 'denom cdr)
    (set 'make cons)
    (setq one-half (make 1 2))
    (princ (strcat "\nNumerator: " (itoa (numer one-half))))
    (princ (strcat "\nDenominator: " (itoa (denom one-half))))

    (if (eq (type (numer one-half)) 'STRING)
      "Our fraction is broken!"
      )

    (princ)
    )
 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;I would love to be able to include elegant coding such as this, but I'd need to study and understand it. I kind of get the gist of it, but since I'm under the gun for solutions right now I'll have to tuck this away until I have more time to make sure it all sinks in. I appreciate the insight though John. Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 22:32:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-text-from-a-list/m-p/12466311#M20220</guid>
      <dc:creator>DGCSCAD</dc:creator>
      <dc:date>2023-12-28T22:32:47Z</dc:date>
    </item>
  </channel>
</rss>

