anandhan 发表于 2022-7-5 20:03:28

这么做的简单方法???

嗨,frids,
 
如果有任何其他方法可以简单地完成此程序。。请帮帮我
plpl。csv

pBe 发表于 2022-7-5 20:08:04

将字符串内容从读取行转换为列表
 
删除所有“,”
将字符串转换为列表
使用另一个列表进行比较检查
 
避免使用多个“如果”,而是使用cond或while函数在满足条件时终止评估

SLW210 发表于 2022-7-5 20:10:46

请使用代码标签,而不是代码的引号标签。
 
代码发布指南

anandhan 发表于 2022-7-5 20:13:35

(defun c:exc()

(setq f (findfile "plpl.csv"))

(setq g (open f "r"))

(setq tmpstr 0)

(while (/= tmpstr nil)

(cond

(
(setq tmpstr (read-line g))
(assing_val)
)
)
)
(princ))


(defun assing_val ()

(setq idx (strlen tmpstr))


;Pipe length

(if (and (= (substr tmpstr 3 5) "ND,25") (/= (substr tmpstr 8 1) "0")) (setq ND25 (substr tmpstr 9 4) ))
(if (and (= (substr tmpstr 3 5) "ND,50") (/= (substr tmpstr 8 1) "0")) (setq ND50 (substr tmpstr 9 4) ))
(if (and (= (substr tmpstr 3 5) "ND,80") (/= (substr tmpstr 8 1) "0")) (setq ND80 (substr tmpstr 9 4) ))
(if (and (= (substr tmpstr 3 6) "ND,100") (/= (substr tmpstr 9 1) "0")) (setq ND100 (substr tmpstr 10 4)))
(if (and (= (substr tmpstr 3 6) "ND,150") (/= (substr tmpstr 9 1) "0")) (setq ND150 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,200") (/= (substr tmpstr 9 1) "0")) (setq ND200 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,250") (/= (substr tmpstr 9 1) "0")) (setq ND250 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,300") (/= (substr tmpstr 9 1) "0")) (setq ND300 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,350") (/= (substr tmpstr 9 1) "0")) (setq ND350 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,400") (/= (substr tmpstr 9 1) "0")) (setq ND400 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,450") (/= (substr tmpstr 9 1) "0")) (setq ND450 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,500") (/= (substr tmpstr 9 1) "0")) (setq ND500 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,550") (/= (substr tmpstr 9 1) "0")) (setq ND550 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,600") (/= (substr tmpstr 9 1) "0")) (setq ND600 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,650") (/= (substr tmpstr 9 1) "0")) (setq ND650 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,700") (/= (substr tmpstr 9 1) "0")) (setq ND700 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,750") (/= (substr tmpstr 9 1) "0")) (setq ND750 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,800") (/= (substr tmpstr 9 1) "0")) (setq ND800 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,850") (/= (substr tmpstr 9 1) "0")) (setq ND850 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,900") (/= (substr tmpstr 9 1) "0")) (setq ND900 (substr tmpstr 10 5)))
(if (and (= (substr tmpstr 3 6) "ND,950") (/= (substr tmpstr 9 1) "0")) (setq ND950 (substr tmpstr 10 5)))

(if (and (= (substr tmpstr 3 7) "ND,1000") (/= (substr tmpstr 10 1) "0")) (setq ND950 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1050") (/= (substr tmpstr 10 1) "0")) (setq ND1050 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1100") (/= (substr tmpstr 10 1) "0")) (setq ND1100 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1150") (/= (substr tmpstr 10 1) "0")) (setq ND1150 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1200") (/= (substr tmpstr 10 1) "0")) (setq ND1200 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1250") (/= (substr tmpstr 10 1) "0")) (setq ND1250 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1300") (/= (substr tmpstr 10 1) "0")) (setq ND1300 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1350") (/= (substr tmpstr 10 1) "0")) (setq ND1350 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1400") (/= (substr tmpstr 10 1) "0")) (setq ND1400 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1450") (/= (substr tmpstr 10 1) "0")) (setq ND1450 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1500") (/= (substr tmpstr 10 1) "0")) (setq ND1500 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1550") (/= (substr tmpstr 10 1) "0")) (setq ND1550 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1600") (/= (substr tmpstr 10 1) "0")) (setq ND1600 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1650") (/= (substr tmpstr 10 1) "0")) (setq ND1650 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1700") (/= (substr tmpstr 10 1) "0")) (setq ND1700 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1750") (/= (substr tmpstr 10 1) "0")) (setq ND1750 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1800") (/= (substr tmpstr 10 1) "0")) (setq ND1800 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1850") (/= (substr tmpstr 10 1) "0")) (setq ND1850 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1900") (/= (substr tmpstr 10 1) "0")) (setq ND1900 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,1950") (/= (substr tmpstr 10 1) "0")) (setq ND1950 (substr tmpstr 11 5)))
(if (and (= (substr tmpstr 3 7) "ND,2000") (/= (substr tmpstr 10 1) "0")) (setq ND2000 (substr tmpstr 11 5)))


;Elbow length

(princ))

anandhan 发表于 2022-7-5 20:18:31

非常感谢。我为我的程序张贴代码标签。
请用其他方法帮助我?

anandhan 发表于 2022-7-5 20:20:40

“当我阅读CVS文件时,这是一种法律行为,这就是我为什么打电话给我的程序。
 
你能把字符串转换成一个列表吗。请

Stefan BMR 发表于 2022-7-5 20:24:39

(setq l (read-line g))
(setq item (read (strcat "(" (vl-string-translate "," " " l) ")")))

pBe 发表于 2022-7-5 20:28:10

 
 
就像那样

anandhan 发表于 2022-7-5 20:30:32

谢谢你的快速回复。让我试试这个。。。。

pBe 发表于 2022-7-5 20:34:44

这里的常数值是多少?源还是目标?查看if语句,如果值位于excel文件中,则如果满足targetsource或sourcetarget的条件,则为每个值“分配”一个变量。你处理这件事的方式有点奇怪,我认为你做得不对。
 
阿南丹这一套的目的是什么?
页: [1] 2
查看完整版本: 这么做的简单方法???