<?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: Hi please help with strcat and more (Beginner question again!) in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466997#M40086</link>
    <description>Thanks that is very detailed, I will put into practice and hopefully I'll have this ready by EOD :D, it definitelt worthwhile thanks again for your time!&lt;BR /&gt;</description>
    <pubDate>Thu, 06 Oct 2022 20:49:11 GMT</pubDate>
    <dc:creator>vporrash141089</dc:creator>
    <dc:date>2022-10-06T20:49:11Z</dc:date>
    <item>
      <title>Hi please help with strcat and more (Beginner question again!)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466597#M40081</link>
      <description>&lt;P&gt;Hi everybody&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been working this morning on a program to insert the following fl&amp;nbsp; floor number which would be 01,02,03 etc... and I came up with this which ofcourse is not working as desired and I would like some suggestions on how I could accomplish the followint 01.ROOM01 and +1 with every click.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:SVT ()
 
(setq F (getstring "\nEnter floor number"))
(setq stn (getint "Enter starting number"))
	
	(while (setq p (getpoint "\n Pick to insert text"))
		(entmake (list (cons 0 "text")
                       (cons 10 p) 
                       (cons 40 7) 
                       (cons 50 0.0)
                       (cons 1  F ".ROOM" stn ))
		)        
                       
		       (setq stn (+ stn 1))
 )  
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advanced,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Oct 2022 17:51:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466597#M40081</guid>
      <dc:creator>vporrash141089</dc:creator>
      <dc:date>2022-10-06T17:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Hi please help with strcat and more (Beginner question again!)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466640#M40082</link>
      <description>&lt;P&gt;Could you apply the knowledge you’ve learned from replies to your previous post&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-having-issues-with-lisp-beginner-question/td-p/11458807/jump-to/first-unread-message" target="_blank"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-having-issues-with-lisp-beginner-question/td-p/11458807/jump-to/first-unread-message&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 18:04:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466640#M40082</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2022-10-06T18:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Hi please help with strcat and more (Beginner question again!)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466643#M40083</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(defun c:svt (/ f p stn)
  (if (and (/= "" (setq f (getstring "\nEnter floor number"))) (setq stn (getint "Enter starting number")))
    (while (setq p (getpoint "\n Pick to insert text"))
      (entmake
	(list (cons 0 "text") (cons 10 p) (cons 40 7) (cons 50 0.0) (cons 1 (strcat f ".ROOM" (itoa stn))))
      )
      (setq stn (+ stn 1))
    )
  )
  (princ)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to use STRCAT to join all your items and they all need to be text which is why ITOA is used for your getINT stn variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(strcat f ".ROOM" (itoa stn))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;EM&gt;(if (and&lt;/EM&gt; at the beginning checks that all user input is correct then proceeds to the loop.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 18:08:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466643#M40083</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2022-10-06T18:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Hi please help with strcat and more (Beginner question again!)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466909#M40084</link>
      <description>&lt;P&gt;I've dug into the link for my previous questions and this might be silly but I can't figure out how to add the zeros...&lt;/P&gt;&lt;P&gt;The text should read like this 2.ROOM001 but with the option provided on this post zeros do not show up, I'd like to ask if you could maybe give me a hint on how I should make those zeros show up on the entmake text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:SVT (/ f p stn)
  (setvar "clayer" "ROOM")
  (if (and (/= "" (setq f (getstring "\nEnter floor number"))) (setq stn (getint "Enter starting number")))
    (while (setq p (getpoint "\n Pick to insert text"))
      (entmake
		(list (cons 0 "text") (cons 7 "Arial") (cons 10 p) (cons 40 7) (cons 50 0.0) (cons 1 (strcat f ".ROOM" (itoa stn))))
      )
      (setq stn (+ stn 1))
    )
  )
  (princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Oct 2022 19:57:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466909#M40084</guid>
      <dc:creator>vporrash141089</dc:creator>
      <dc:date>2022-10-06T19:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Hi please help with strcat and more (Beginner question again!)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466988#M40085</link>
      <description>&lt;P&gt;sure..in my response to your first post I showed you the following code to test the length of the text string &lt;STRONG&gt;r&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;(setq len (strlen &lt;STRONG&gt;r&lt;/STRONG&gt;))&lt;BR /&gt;(cond&lt;BR /&gt;((= 1 len)(setq &lt;STRONG&gt;r&lt;/STRONG&gt; (strcat "000" &lt;STRONG&gt;r&lt;/STRONG&gt;))&lt;BR /&gt;((= 2 len)(setq &lt;STRONG&gt;r&lt;/STRONG&gt; (strcat "00" r))&lt;BR /&gt;((= 3 len)(setq &lt;STRONG&gt;r&lt;/STRONG&gt; (strcat "0" &lt;STRONG&gt;r&lt;/STRONG&gt;))&lt;BR /&gt;(t (princ"\nNumber is greater than 4 digits"))&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;In that case &lt;STRONG&gt;r&lt;/STRONG&gt; represented the value of the text string you wanted to use.&lt;/P&gt;&lt;P&gt;Now you have two text strings you need to test:&amp;nbsp;&lt;STRONG&gt;f&lt;/STRONG&gt; and&lt;STRONG&gt; stn:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(cons 1 F ".ROOM" stn) &lt;/STRONG&gt;; but this is incorrectly coded because again like before you need to convert &lt;STRONG&gt;stn&lt;/STRONG&gt; from an integer to a string using function &lt;STRONG&gt;itoa&lt;/STRONG&gt; and then connect the text strings together using function &lt;STRONG&gt;strcat&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(cons 1 (strcat F ".ROOM" (itoa stn)))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Also, this time you only need to test if the length of the text string is 1 character and then add the zero in front.&lt;/P&gt;&lt;P&gt;So you can either run this revised code 2x like this:&lt;/P&gt;&lt;P&gt;(setq len (strlen &lt;STRONG&gt;F&lt;/STRONG&gt;))&lt;BR /&gt;(if(= 1 len)(setq &lt;STRONG&gt;F&lt;/STRONG&gt; (strcat "0" &lt;STRONG&gt;F&lt;/STRONG&gt;))) ; adds 0 in front only if character length is 1 which takes care of &lt;STRONG&gt;F&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(setq &lt;STRONG&gt;G&lt;/STRONG&gt; (itoa stn)) ; save the converted # to string as &lt;STRONG&gt;G&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(setq len (strlen &lt;STRONG&gt;G&lt;/STRONG&gt;)) ; get the length&lt;/P&gt;&lt;P&gt;(if(= 1 len)(setq &lt;STRONG&gt;G&lt;/STRONG&gt; (strcat "0" &lt;STRONG&gt;G&lt;/STRONG&gt;))) ; adds 0 in front only if character length is 1 which takes care of &lt;STRONG&gt;G&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Now your entmake text string code should look like this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(cons 1 (strcat F ".ROOM" G))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Now another more efficient way is to create a sub routine or another function that you will run like the above more than once that I'm calling chk_str. This function will pass the text string &lt;STRONG&gt;str&lt;/STRONG&gt; as the argument to test and return text string with the added zero if needed:&lt;/P&gt;&lt;P&gt;(defun &lt;STRONG&gt;chk_str&lt;/STRONG&gt; (str / len newstr)&lt;/P&gt;&lt;P&gt;&amp;nbsp;(setq len (strlen &lt;STRONG&gt;str&lt;/STRONG&gt;))&lt;BR /&gt;&amp;nbsp;(if(= 1 len)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;(setq &lt;STRONG&gt;newstr&lt;/STRONG&gt; (strcat "0" &lt;STRONG&gt;str&lt;/STRONG&gt;))&amp;nbsp;; adds 0 in front only if character length is 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;(setq &lt;STRONG&gt;newstr&lt;/STRONG&gt; &lt;STRONG&gt;str&lt;/STRONG&gt;) ; no changes needed&lt;/P&gt;&lt;P&gt;&amp;nbsp;)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;newstr&lt;/STRONG&gt; ; return&lt;/P&gt;&lt;P&gt;) ; defun&lt;/P&gt;&lt;P&gt;This time your entmake text string code would look like this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(cons 1 (strcat (chk_str F) ".ROOM" (chk_str (itoa stn))))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;putting it all together the updated code will look like this (not tested):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:SVT (/ chk_str F p stn) ; localize functions &amp;amp; symbols
; chk_str function passes the text string str as the argument to test and 
; return text string with the added zero if needed
 (defun chk_str (str / len newstr)
  (setq len (strlen str))
  (if(= 1 len)
   (setq newstr (strcat "0" str)) ; adds 0 in front only if character length is 1
   (setq newstr str) ; no changes needed
  )
  newstr ; return
 ) ; defun
 (setq F (getstring "\nEnter floor number: "))
 (setq stn (getint "Enter starting number: "))
  (while (setq p (getpoint "\n Pick to insert text"))
	(entmake 
          (list
            (cons 0 "text")
            (cons 10 p) 
            (cons 40 7) 
            (cons 50 0.0)
            (cons 1 (strcat (chk_str F) ".ROOM" (chk_str (itoa stn)))) ; revised code
          ) ; list
	) ; entmake                            
	(setq stn (+ stn 1))
  ) ; while
  (princ)
) ; defun&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 20:45:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466988#M40085</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2022-10-06T20:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Hi please help with strcat and more (Beginner question again!)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466997#M40086</link>
      <description>Thanks that is very detailed, I will put into practice and hopefully I'll have this ready by EOD :D, it definitelt worthwhile thanks again for your time!&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Oct 2022 20:49:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11466997#M40086</guid>
      <dc:creator>vporrash141089</dc:creator>
      <dc:date>2022-10-06T20:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Hi please help with strcat and more (Beginner question again!)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11467011#M40087</link>
      <description>&lt;P&gt;You are welcome again. Now the real learning bregins when you start applying what you’ve learned...cheers!!!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 20:55:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11467011#M40087</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2022-10-06T20:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Hi please help with strcat and more (Beginner question again!)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11468152#M40088</link>
      <description>&lt;P&gt;Another little question/suggestion:&lt;/P&gt;
&lt;P&gt;Do you ever have &lt;EM&gt;floor numbers less than one&lt;/EM&gt; [presumably basement levels]?&amp;nbsp; If not, I would suggest that you use&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (getint)&lt;/FONT&gt; &lt;/STRONG&gt;&lt;/FONT&gt;for the floor number, rather than&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (getstring)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;.&amp;nbsp; That way, you can prevent certain kinds of errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;(initget 7)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#00CCFF"&gt;; for next (get...) function, no Enter [1]. no zero [2], no negative [4] -- 7 = 1+2+4&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;(setq&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; F (get&lt;FONT color="#0000FF"&gt;int&lt;/FONT&gt; "\nEnter floor number")&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; F (itoa F)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#00CCFF"&gt;; turn into string for further processing&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The advantage is that it both requires input [no Enter], and requires an &lt;EM&gt;appropriate&lt;/EM&gt; input.&amp;nbsp; If an inappropriate one is given, it does not just proceed anyway, which would happen if you missed the right key and typed, for example, "W" in other code here.&amp;nbsp; Instead, it asks again, &lt;EM&gt;until&lt;/EM&gt; you do give it an appropriate input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do use floor number 0 for a basement level, you can use&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (initget 5)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;; if you use negatives,&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (initget 1)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;.&amp;nbsp; With some additional code, it can also be made to remember the last floor number you gave it, and offer that as the default on subsequent use, in which Enter would also be allowed.&amp;nbsp; If all are allowed,&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (initget)&lt;/FONT&gt; &lt;/STRONG&gt;&lt;/FONT&gt;wouldn't be needed, but using&lt;FONT face="courier new,courier" color="#000000"&gt;&lt;STRONG&gt; (getint)&lt;/STRONG&gt; &lt;/FONT&gt;would still have the benefit of preventing non-whole-number entries.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 11:45:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hi-please-help-with-strcat-and-more-beginner-question-again/m-p/11468152#M40088</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2022-10-07T11:45:19Z</dc:date>
    </item>
  </channel>
</rss>

