从numrical更改变量
当从图形中检索信息到lisp时,我得到五个didget中的一个,每个didget代表一种材料。1 for lead
2 = zinc
3 = ceramic
4 = concrete
5 = synthetic
这些值存储在变量中,并写入excel。
而不是让excel文件解决问题,我如何使用lisp引用/索引相应材料的数字?
因此,与其使用excel,不如使用:
1
1
2
1
3
1
4
2
我有一个excel文件,其中包含:
Lead
Lead
Zinc
Lead
Ceramic
Lead
Concrete
Zinc
关联列表对于这种类型的数据非常有用
(setq matdata '(
("LEAD" . 1)
("ZINC" . 2)
("CERAMIC" . 3)
("CONCRETE" . 4)
("SYNTHETIC" . 5)
))
然后:
(cdr (assoc value matdata))
但是,它们区分大小写。或者可以根据您的需要进行反转-大卫 在将值写入excel文件之前,请使用cond语句。
例子:
;; Get variable value
(setq var 1)
;; Interpret value prior to write
(cond
((= 1 var)
(setq var "Lead"))
((= 2 var)
(setq var "Zinc"))
((= 3 var)
(setq var "Ceramic"))
((= 4 var)
(setq var "Concrete"))
;; ...etc.
)
;; Write variable to excel
也许这种格式更可取?
(setq matdata '((1 . "LEAD")
(2 . "ZINC")
(3 . "CERAMIC")
(4 . "CONCRETE")
(5 . "SYNTHETIC")
))
我无法从OP上判断他们需要数据的方式。。。。。
页:
[1]