Lisp option malfunction

Lisp option malfunction

josuecortez007
Participant Participant
370 Views
4 Replies
Message 1 of 5

Lisp option malfunction

josuecortez007
Participant
Participant

Hi guys, i am traying to get this quick update lisp  to work but do not know what I am missing.

I want the lisp to give  me the option to pick what option i want it to execute.  This is what i got so far , i am kinda new to writing lisp.

 

(defun c:quick update ( / ans do_A do_B)
(defun do_A)
(foreach layout (layoutlist)
(setvar "ctab" layout)
(command ".-ATTEDIT" "N" "N" "*" "06" "*" "value" "value")
(command ".-ATTEDIT" "N" "N" "*" "R2A" "*" "" "value")
(command ".-ATTEDIT" "N" "N" "*" "R2B" "*" "" "value")
);foreach)

(defun do_B)
(foreach layout (layoutlist)
(setvar "ctab" layout)
(command ".-ATTEDIT" "N" "N" "*" "R2D" "*" "" "name")
(command ".-ATTEDIT" "N" "N" "*" "R2E" "*" "" "name")
(command ".-ATTEDIT" "N" "N" "*" "R2F" "*" "" "name")
(command ".-ATTEDIT" "N" "N" "*" "R2G" "*" "" "name")
(command "zoom" "e")
);foreach

;; then use getkword...

(initget "1" "2")
(setq ans (getkword "\nSelect a topping [1/2/] <1: "))
(cond
((or (not ans)(= ans "1"))(do_A))
((= ans "2")(do_B))

);end_defun

 

 

 

 

0 Likes
371 Views
4 Replies
Replies (4)
Message 2 of 5

CADaSchtroumpf
Advisor
Advisor

You have made mistakes

(defun do_A) (xxx.....)


should be (defun do_A (xxx...))

 

c:quick update should not contain spaces

 

(initget "1" "2") -> rather (initget "1 2")

 

This would be shorter, but I didn't test ("name" and "value" intrigue me; are they strings or variables?)

(defun c:quick_update ( / ans l)
  (initget "1 2")
  (setq ans (getkword "\nSelect a topping [1/2/] <1>: "))
  (cond
    ((eq ans "2")
      (setq l '("R2D" "R2E" "R2F" "R2G"))
    )
    (T
      (setq l '("06" "R2A" "R2B"))
    )
  )
  (foreach layout (layoutlist)
    (setvar "ctab" layout)
    (mapcar
      '(lambda (x)
        (command "_.-ATTEDIT" "_N" "_N" "*" x "*" "" (if (eq ans 2) "name" "value"))
      )
      l
    )
  )
  (prin1)
)
0 Likes
Message 3 of 5

john.uhden
Mentor
Mentor

@josuecortez007 ,

I don't have the -ATTEDIT command memorized, so I can't help with that.

But here are some edits in red...

(defun c:quick_update ( / ans do_A do_B)
(defun do_A ()
(foreach layout (layoutlist)
(setvar "ctab" layout)
(command ".-ATTEDIT" "N" "N" "*" "06" "*" "value" "value")
(command ".-ATTEDIT" "N" "N" "*" "R2A" "*" "" "value")
(command ".-ATTEDIT" "N" "N" "*" "R2B" "*" "" "value")
);foreach

) ; end defun do_A

(defun do_B ()
(foreach layout (layoutlist)
(setvar "ctab" layout)
(command ".-ATTEDIT" "N" "N" "*" "R2D" "*" "" "name")
(command ".-ATTEDIT" "N" "N" "*" "R2E" "*" "" "name")
(command ".-ATTEDIT" "N" "N" "*" "R2F" "*" "" "name")
(command ".-ATTEDIT" "N" "N" "*" "R2G" "*" "" "name")
(command "zoom" "e")
);foreach

) ; end defun do_B

;; then use getkword...

(initget "1" "2")
(setq ans (getkword "\nSelect a topping [1/2/] <1>: "))
(cond
((or (not ans)(= ans "1"))(do_A))
((= ans "2")(do_B))

);end_defun

John F. Uhden

0 Likes
Message 4 of 5

josuecortez007
Participant
Participant

The name, and value are attribute tag value that were there as a temporary place holder. 

 

0 Likes
Message 5 of 5

josuecortez007
Participant
Participant

Thanks this worked good, I just would like to be able to change easily the values  for (setq l '("06" "R2A" "R2B")) since they are different from the second part.

0 Likes