svorgodne Posted September 28, 2017 Author Posted September 28, 2017 I cannot make it work in any case... thanks a lot to all for your comments. I tried to simplify as much as I could the explanation. Here is my last code. It has to work like this somehow because all other variables aredone already and it woulkd imply a lot of changes in my source coding. Basically I would have to re-write the whole routine. Can anybody help me? Please? (defun c:Test () (setq LST_TST (list '("TST1" "c" "1") '("TST2" "c" "t" "0,76,38") ) ) (defun sw () (cond ( (= SYM_TST nil) (setq SYM_TST 1) ) ( (= SYM_TST 1) (setq SYM_TST 2) ) ( (= SYM_TST 2) (setq SYM_TST 1) ) ) (print SYM_TST) (princ) ) (sw) (command "-layer" "m" (cond ( (= SYM_TST 1) (nth 0 (nth 0 LST_TST) ) (nth 1 (nth 0 LST_TST) ) (nth 2 (nth 0 LST_TST) ) (nth 0 (nth 0 LST_TST) ) "" ) ( (= SYM_TST 2) ( (= SYM_TST 1) (nth 0 (nth 1 LST_TST) ) (nth 1 (nth 1 LST_TST) ) (nth 2 (nth 1 LST_TST) ) (nth 0 (nth 1 LST_TST) ) "" ) ) ) ) ) Thanks again in advance Quote
svorgodne Posted September 28, 2017 Author Posted September 28, 2017 This code is working but I think it is a dirty way to solve the problem and not duplicating the code and making it dependant on a variable: (defun c:Test () (setq LST_TST (list '("0" "c" "1") '("0" "c" "t" "0,76,38") ) ) (defun sw () (cond ( (= SYM_TST nil) (setq SYM_TST 1) ) ( (= SYM_TST 1) (setq SYM_TST 2) ) ( (= SYM_TST 2) (setq SYM_TST 1) ) ) (print SYM_TST) (princ) ) (sw) (cond ( (= SYM_TST 1) (command "-layer" "m" (nth 0 (nth 0 LST_TST) ) (nth 1 (nth 0 LST_TST) ) (nth 2 (nth 0 LST_TST) ) (nth 0 (nth 0 LST_TST) ) "s" "0" "" ) ) ( (= SYM_TST 2) (command "-layer" "m" (nth 0 (nth 1 LST_TST) ) (nth 1 (nth 1 LST_TST) ) (nth 2 (nth 1 LST_TST) ) (nth 3 (nth 1 LST_TST) ) (nth 0 (nth 1 LST_TST) ) "s" "0" "" ) ) ) ) Thanks again and really hoping someone to help to do it shorter. Quote
Roy_043 Posted September 28, 2017 Posted September 28, 2017 Following BIGAL's strlen suggestion: (defun c:Test ( / LST_TST) (setq LST_TST '( ("TST1" "1") ("TST2" "0,76,38") ) ) (command "_.-layer") (foreach sub LST_TST (command "_make" (car sub) "_color") (if (> (strlen (cadr sub)) 3) (command "_true")) (command (cadr sub) "") ) (command "_set" "0" "") (princ) ) Quote
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.