Wwx95 Posted June 8, 2016 Share Posted June 8, 2016 (edited) (defun c:sbb(/a b) ((setq a 10 b 5) (if (> a b) (progn (princ a) (setq a (+ a 5) b (+ b 6)) ((princ a)(princ)) ((princ b)(princ)) ) ) ) ) Edited June 13, 2016 by SLW210 Added Code Tags Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 9, 2016 Share Posted June 9, 2016 Way to many brackets Quote Link to comment Share on other sites More sharing options...
SLW210 Posted June 9, 2016 Share Posted June 9, 2016 Please post in the proper forum, I moved your thread to the AutoLISP, Visual LISP & DCL Forum. Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. [NOPARSE] Your Code Here [/NOPARSE] = Your Code Here Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 9, 2016 Share Posted June 9, 2016 (defun c:sbb ( / a b ) ;( this isn't required (setq a 10 b 5) (if (> a b) (progn (princ a) (setq a (+ a 5) b (+ b 6)) ;( this isn't required (princ a) ;(princ) This can be replaced by one final (princ) this isn't required ;( this isn't required (princ b) ;(princ) This can be replaced by one final (princ) this isn't required ) ;; end progn ) ;; end if (princ) ;; This can replace the earlier (princ) expressions this isn't required ) ;; end defun Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 10, 2016 Share Posted June 10, 2016 Thanks Lee I thought I would give time for Wwx95 to have a go first. Nice touch the ;;defun I often do this for ;if's etc so you can keep count and make sure closing brackets. Quote Link to comment Share on other sites More sharing options...
Wwx95 Posted June 10, 2016 Author Share Posted June 10, 2016 Thanks, I am new here, and I changed my code according to your code,is it like this? (defun c:sbb (/ a b) (if (> a b) (progn (princ a) (setq a (+ a 5) b (+ b 6)) ) ) ) But how can I run it in CAD? Like this? (setq a 10 b 5) (sbb a b) It doesn't work, and told me "error: no function definition: SBB" Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 10, 2016 Share Posted June 10, 2016 Thanks Lee I thought I would give time for Wwx95 to have a go first. Nice touch the ;;defun I often do this for ;if's etc so you can keep count and make sure closing brackets. Thank you Al But how can I run it in CAD? Like this? (setq a 10 b 5) (sbb a b) It doesn't work, and told me "error: no function definition: SBB" If you wish to evaluate the function with arguments, you will need to define it in the following way: (defun sbb ( a b ) (if (> a b) (progn (princ a) (setq a (+ a 5) b (+ b 6)) ) ) ) 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.