我完全同意——奇怪的是,从AutoLISP起步的开发人员中,有多少人选择使用单个变量而不是列表。
- (defun CabinList ( l )
- (mapcar
- '(lambda ( x / s )
- (if (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "*_" x "_*")))))
- (cons x (sslength s))
- (cons x 0)
- )
- )
- l
- )
- )
- (defun c:cabin ( / lst qry )
- (setq lst (CabinList '("C2" "CC" "CS1" "OFF" "PS1" "PS2" "SO"))
- qry (strcase (getstring "\nEnter a code to find the quantity <all>: "))
- )
- (if (= "" qry)
- (foreach itm lst (princ (strcat "\n" (car itm) ": " (itoa (cdr itm)))))
- (princ (strcat "\n" qry ": " (itoa (cond ((cdr (assoc qry lst))) (0)))))
- )
- (princ)
- )
|