如何获取批量给字符串变量所赋的值?
(defun C:GG(/);; 批量给字符串变量赋值
(setq n 0)
(repeat 8
(setq n (1+ n))
(set (read (strcat "lst_" (itoa n))) (strcat "A_" (itoa n)))
)
;; 如何批量获取变量的值???
(setq n 0)
(repeat 8
(setq n (1+ n))
(princ "\n")
(princ (read (strcat "lst_" (itoa n))))
)
(princ)
)
问题已解决,不好意思
(defun C:GG(/)
;; 批量给字符串变量赋值
(setq n 0)
(repeat 8
(setq n (1+ n))
(set (read (strcat "lst_" (itoa n))) (strcat "a_" (itoa n)))
)
;; 批量获取变量值
(setq n 0)
(repeat 8
(setq n (1+ n))
(setq str(vl-symbol-value (read (strcat "lst_" (itoa n)))))
(princ "\n")
(princ str)
)
(princ)
)
(eval(read (strcat "lst_" (itoa n)))) eval也可以
飞雪神光 发表于 2023-9-15 22:50
(eval(read (strcat "lst_" (itoa n)))) eval也可以
感谢大佬解惑 (defun c:tt (/)
"批量给字符串变量赋值"
(setq n 0
lst '()
)
(repeat 8
(setq n (1+ n)
a (strcat "lst_" (itoa n))
b (strcat "a_" (itoa n))
lst (cons a lst)
)
(set (read a) b)
)
"批量获取变量值"
(setq lst (reverse lst))
(princ (mapcar '(lambda (x) (eval (read x))) lst))
(princ)
) xyp1964 发表于 2023-9-15 23:41
谢谢,了解了
页:
[1]