Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get trouble in using princ in Autolisp

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
maikhanhmst
561 Views, 2 Replies

Get trouble in using princ in Autolisp

Hi there,

 

I'm total new to Autolisp. I'm trying to familar with it by programming some simple statements.

I'm in trouble with the below program when I used princ function. Please take a look at my program.

 

(defun c:sum()
(setq a (getint "Number1: "))
(setq b (getint "Number2: "))
(setq sum (+ a b))
(princ sum)(princ)
)

 

When I enter values of Number 1 and Number 2 are 10 and 30, the result displaying in AutoCAD command is 3030 instead of 30.

I've have been searching but nothing can work in my situation.

Could anyone help me with this?

 

Thank you.

 

Khanh

 

 

2 REPLIES 2
Message 2 of 3
hgasty1001
in reply to: maikhanhmst

Hi,

 

I can't reproduce the problem and that's the way it should be, as the last princ returns a null symbol that it's not printed to the command line, lisp always returns the last evaluated variable or expression in a function, in this case the last evaluated expression is (princ). So look again the code, as you may be missing the last (princ) in your executing code.

 

 

Gaston Nunez

 

 

Message 3 of 3
maikhanhmst
in reply to: hgasty1001

Hi Gastson,

My problem's been solved. I just missed a (princ) at the last line as you said. Thank you so much.

Khanh.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost