New to AutoLISP

Discussion of other Lisp dialects (Arc, Clojure, AutoLisp, XLISP, etc.)
Post Reply
duanuys
Posts: 1
Joined: Fri Apr 04, 2014 2:37 pm

New to AutoLISP

Post by duanuys » Fri Apr 04, 2014 2:43 pm

I am very knowledgable in AutoCAD. In my opinion is the best drafting software out there, but I just recently entered the world of coding, kind of jumping around between languages, giving them a shot. I have done this and know i have a very moderate knowledge of how programming works.. there is always something similiar doesn't matter how different the languages can be. Then i went back to my AutoCAD and starting learning about AutoLISP. WHich from the little education i have on it, i can already see all the fantastic things I can do with it to help me with my job. I was wondering if the community can help me here.

Pretty much I want a user to input a number and if its a choice of three, then have that number be assigned to a variable.. Here is the code i have so far, its very basic.. so hopefully it won't be too hard to answer. This wont' compile.. or i guess in this language, it won't run correctly. can anyone please help me out here? Any input would greatly be appreciated!

Code: Select all

(defun c:typewell()
  	(setq choice (getdist "\nCreate: Oil(1) , Gas(2), or Water(3)"))
  	(if (= choice 1))
  		(progn
		  (alert "You chose Oil")
		)
  	)
       
)
(princ)

edgar-rft
Posts: 226
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: New to AutoLISP

Post by edgar-rft » Sat Apr 05, 2014 5:08 am

I have no particular knowledge about AutoLisp (because I don't have AutoCad) but according to standard Lisp syntax rules there is one closing paren too many:

Code: Select all

(defun c:typewell()
     (setq choice (getdist "\nCreate: Oil(1) , Gas(2), or Water(3)"))
     (if (= choice 1))  <-- remove one closing paren here
        (progn
        (alert "You chose Oil")
      )
     )
       
)
(princ)

Post Reply