<?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: Error too many Arguments (AKA I can't figure out what's wrong with my code) in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816679#M124615</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Tornac wrote:&lt;BR /&gt;
&lt;P&gt;Are you missing a progn to do three things in the if statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if (eq h 0)
  (progn
		(setq sag (/ (* weight lsqr) (* 8 tension)))
		
		;sag at
		(setq x_sag (/ l &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/FONT&gt;)) ;better with dot -&amp;gt; &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt;&lt;/FONT&gt;
		(setq y_sag (- y0 sag))
  )
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Could be solved by using one (setq) for more variables too...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if (eq h 0)
  (setq sag (/ (* weight lsqr) (* 8 tension)))
  (setq x_sag (/ l 2)
        y_sag (- y0 sag))
)&lt;/PRE&gt;
&lt;P&gt;BTW be careful with dividing by an INTEGER! (/ l 2)&lt;/P&gt;
&lt;P&gt;If your l would be an integer (e.g. 3), then result would be an integer as well!! (/ 3 2) = 1 !!!&lt;/P&gt;
&lt;P&gt;If you not sure what l gonna be, the use a real: (/ l 2.) = see the dot! Atleast one of those members has to be a real to get a real. (/ 3 2.) = 1.5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jan 2017 16:20:24 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2017-01-19T16:20:24Z</dc:date>
    <item>
      <title>Error too many Arguments (AKA I can't figure out what's wrong with my code)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816297#M124611</link>
      <description>&lt;P&gt;I work in transmission engineering, and for a small exercise to learn some AutoLISP in my downtime I wrote a code to calculate and plot the sag of a line in AutoCAD. It looks right to me, but AutoCAD says there's are too many arguments in one section (Lines 30 to 36). I've compared that section to similar sections in other LISP programs I've written, and I can't seem to find the error. What am I missing? I've put the section I'm having issues with in bold red.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;; goal: make an autocad program that can plot accurate sagging for lines

(defun c:autosag ()
	;---------User Inputs-----------
	(setq p1 (getpoint "Choose starting pole"))
	(setq p2 (getpoint "Choose ending pole"))
	(setq tension (getint "Tension: "))
	(setq weight (getint "Weight per unit length: "))
	
	;--------- Snapping ----------------
	(setq oldsnap (getvar "osmode"))
	(setq oldblipmode (getvar "blipmode"))
	
	;switch off system variables
	(setvar "osmode" 0)
	(setvar "blipmode" 0)
	
	;---------Find X&amp;amp;Y values-------
	(setq x0 (car p1))
	(setq y0 (cadr p1))
	
	(setq xf (car p2))
	(setq yf (cadr p2))
	
	(setq l (- xf x0))
	(setq h (- yf y0))
	
	(setq lsqr (* l l))
	
	&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(if (eq h 0)
		(setq sag (/ (* weight lsqr) (* 8 tension)))
		
		;sag at
		(setq x_sag (/ l 2))
		(setq y_sag (- y0 sag))
	)&lt;/STRONG&gt;&lt;/FONT&gt;
	(if (/= h 0)
		;Find x1 &amp;amp; x2
		(setq x1 (- (/ l 2) (/ (* tension h) (* weight l))))
		(setq x2 (+ (/ l 2) (/ (* tension h) (* weight l))))
		
		;Find sag
		(setq sag (/ (* weight (* x1 x1)) (* 2 tension)))
		
		;sag at
		(setq x_sag (+ x0 x1))
		(setq y_sag (- y0 sag))
	)
	
	;xy variable
		(setq sagPoint '(x_sag y_sag))
	
	;---------Draw the Curve------
	(command "spline"
	p1
	sagPoint
	p2
	)
	
	(setvar "osmode" oldsnap)
	(setvar "blipmode oldblipmode")
)&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2017 14:42:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816297#M124611</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-19T14:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Error too many Arguments (AKA I can't figure out what's wrong with my code)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816382#M124612</link>
      <description>&lt;P&gt;Are you missing a progn to do three things in the if statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(if (eq h 0)
  (progn
		(setq sag (/ (* weight lsqr) (* 8 tension)))
		
		;sag at
		(setq x_sag (/ l 2))
		(setq y_sag (- y0 sag))
  )
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:05:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816382#M124612</guid>
      <dc:creator>Satoews</dc:creator>
      <dc:date>2017-01-19T15:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error too many Arguments (AKA I can't figure out what's wrong with my code)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816450#M124613</link>
      <description>&lt;P&gt;Looks like you would be right! I was unaware of the progrn function. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:20:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816450#M124613</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-19T15:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error too many Arguments (AKA I can't figure out what's wrong with my code)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816461#M124614</link>
      <description>&lt;P&gt;No problem, glad I could help!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:24:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816461#M124614</guid>
      <dc:creator>Satoews</dc:creator>
      <dc:date>2017-01-19T15:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error too many Arguments (AKA I can't figure out what's wrong with my code)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816679#M124615</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Tornac wrote:&lt;BR /&gt;
&lt;P&gt;Are you missing a progn to do three things in the if statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if (eq h 0)
  (progn
		(setq sag (/ (* weight lsqr) (* 8 tension)))
		
		;sag at
		(setq x_sag (/ l &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/FONT&gt;)) ;better with dot -&amp;gt; &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt;&lt;/FONT&gt;
		(setq y_sag (- y0 sag))
  )
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Could be solved by using one (setq) for more variables too...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if (eq h 0)
  (setq sag (/ (* weight lsqr) (* 8 tension)))
  (setq x_sag (/ l 2)
        y_sag (- y0 sag))
)&lt;/PRE&gt;
&lt;P&gt;BTW be careful with dividing by an INTEGER! (/ l 2)&lt;/P&gt;
&lt;P&gt;If your l would be an integer (e.g. 3), then result would be an integer as well!! (/ 3 2) = 1 !!!&lt;/P&gt;
&lt;P&gt;If you not sure what l gonna be, the use a real: (/ l 2.) = see the dot! Atleast one of those members has to be a real to get a real. (/ 3 2.) = 1.5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:20:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816679#M124615</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2017-01-19T16:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Error too many Arguments (AKA I can't figure out what's wrong with my code)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816792#M124616</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;BTW be careful with dividing by an INTEGER! (/ l 2)&amp;nbsp; ....&lt;/P&gt;
&lt;P&gt;If you not sure what l gonna be, the use a real: (/ l 2.) = see the dot! Atleast one of those members has to be a real to get a real. (/ 3 2.) = 1.5&lt;/P&gt;
&lt;HR /&gt;That's not necessary in this case -- they &lt;EM&gt;are&lt;/EM&gt; sure what the 'l' variable is gonna be.&amp;nbsp; It's a result of calculations based on coordinates of points, and those are always real numbers, so 'l' will also always be a real number, so the integer divider will not cause any problem.&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:51:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816792#M124616</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-01-19T16:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error too many Arguments (AKA I can't figure out what's wrong with my code)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816848#M124617</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;....&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Could be solved by using one (setq) for more variables too...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if (eq h 0)
  (setq sag (/ (* weight lsqr) (* 8 tension)))
  (setq x_sag (/ l 2)
        y_sag (- y0 sag))
)&lt;/PRE&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Didn't go quite far enough.&amp;nbsp; &lt;EM&gt;All three&lt;/EM&gt; of those settings should be in &lt;EM&gt;one&lt;/EM&gt; (setq) function if you want to eliminate the need for the (progn) "wrapper."&amp;nbsp; And to go even further, the original has an (if) test with something to do if h is 0, and &lt;EM&gt;another&lt;/EM&gt; (if) test for something else to do if it's &lt;EM&gt;not&lt;/EM&gt; 0.&amp;nbsp; Those can be collapsed into &lt;EM&gt;one&lt;/EM&gt; (if) function -- if it's 0, do this, otherwise, do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;(if (= h 0)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (setq &lt;FONT color="#33cccc"&gt;; 'then' expression&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sag (/ (* weight lsqr) (* 8 tension))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x_sag (/ l 2)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;y_sag (- y0 sag)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; ); setq&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &lt;/FONT&gt;(setq &lt;FONT color="#33cccc"&gt;; 'else' expression&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1 (- (/ l 2) (/ (* tension h) (* weight l)))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x2 (+ (/ l 2) (/ (* tension h) (* weight l)))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sag (/ (* weight (* x1 x1)) (* 2 tension))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x_sag (+ x0 x1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y_sag (- y0 sag)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ); setq&lt;BR /&gt; ); if&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 17:02:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-too-many-arguments-aka-i-can-t-figure-out-what-s-wrong/m-p/6816848#M124617</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-01-19T17:02:29Z</dc:date>
    </item>
  </channel>
</rss>

