Perifanos Posted March 3, 2013 Share Posted March 3, 2013 (defun C:Heatest() (Princ "Define Area:") (Command "area") (while (= 1 (getvar "cmdactive")) (command pause) ) (setq A (getvar "area")) (princ A) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 3, 2013 Share Posted March 3, 2013 Firstly, please read the Code Posting Guidlines for instructions on how to format code in your posts and please edit your post as required. I don't see anything in your code that would cause an error, however, there is the possibility that you have inadvertently redefined the pause symbol to something other than "\\", and you have also not declared the symbol a as a local variable (for more information on variable localisation, see my tutorial here). Here is an alternative way to write your code: (defun c:heatest ( ) (command "_.area") (while (< 0 (getvar 'cmdactive)) (command "\\") ) (princ (getvar 'area)) (princ) ) Quote Link to comment Share on other sites More sharing options...
Perifanos Posted March 3, 2013 Author Share Posted March 3, 2013 (defun c:heatest (/ a) (command "_.area") (while (< 0 (getvar 'cmdactive)) (command "\\") ) (princ "Area:" (getvar 'area)) ) I have just Copy/Pasted your code above, adding a string after princ. I get this error: ; error: bad argument type: FILE I dont know what is wrong, really. Quote Link to comment Share on other sites More sharing options...
Perifanos Posted March 3, 2013 Author Share Posted March 3, 2013 (defun c:heatest (/a) (setq a 10) (princ a) ) And if the previous is difficult, read this one...I get the same error... Quote Link to comment Share on other sites More sharing options...
David Bethel Posted March 3, 2013 Share Posted March 3, 2013 The sysvar AREA is stored a a REAL number. You can : (prin1 ... or (princ (rtos ... -David Quote Link to comment Share on other sites More sharing options...
Perifanos Posted March 3, 2013 Author Share Posted March 3, 2013 So what is wrong with this: (defun c:heatest () (setq a 10 b 20) (princ (a b)) (princ) ) Quote Link to comment Share on other sites More sharing options...
fixo Posted March 3, 2013 Share Posted March 3, 2013 Man, have you tried to read about LIST function? Just interesting to know Here is good place I'll recommend to start from www.afralisp.net Try (setq a 10 b 20) (princ (list a b)) (terpri) (print (list a b)) (terpri) (princ (vl-princ-to-string (list a b))) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 3, 2013 Share Posted March 3, 2013 I dont know what is wrong, really. This is the source of the error: I have just Copy/Pasted your code above, adding a string after princ. You also removed the final call to princ for some reason. The princ function accepts two optional arguments: a string to print to the command-line or to a file, and a file descriptor (if printing to file). You have supplied the string "Area:" as the first argument, and (getvar 'area) as the second argument. However, (getvar 'area) is not a file descriptor as expected by princ for the second argument, hence the error. To print the string "Area:" followed by the value of (getvar 'area), you will need to either convert the area value to a string using the rtos function, and then use strcat to concatenate the two strings; or use a separate princ expression to print the area value: (defun c:heatest ( / a ) (command "_.area") (while (< 0 (getvar 'cmdactive)) (command "\\") ) (princ (strcat "Area:" (rtos (getvar 'area)))) (princ) ) (defun c:heatest ( / a ) (command "_.area") (while (< 0 (getvar 'cmdactive)) (command "\\") ) (princ "Area:") (princ (getvar 'area)) (princ) ) As for your other posts, I suggest that you first read the AutoLISP Documentation and visit a few AutoLISP tutorial sites to determine the cause of your errors. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.