事实上,我需要的是在文本文件中保存以下格式的列表:
(("Nome da Obra" "Nome do Cliente" "RSP007-2016" "Rua sem nome s/n") (((SPT01 0.11 1.15) (1/35 3/33 4/31 1 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT02 0.22 2.15) (2/35 3/33 4/31 2 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT03 0.33 3.15) (3/35 3/33 4/31 3 18 7/31 8 7/31 9 15 15 24 25 28 26 26 31 30 29 33 32 30 31 34 40 66)) ((SPT04 0.44 4.15) (4/35 3/33 4/31 4 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT05 0.55 5.15) (5/35 3/33 4/31 5 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT06 0.66 6.15) (6/35 3/33 4/31 6 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT07 0.77 7.15) (7/35 3/33 4/31 7 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT08 0.88 8.15) (8/35 3/33 4/31 8 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT09 0.99 9.15) (9/35 3/33 4/31 9 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT10 1.11 10.15) (10/35 3/33 4/31 10 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT11 1.22 11.15) (11/35 3/33 4/31 11 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43)) ((SPT12 1.33 12.15) (12/35 3/33 4/31 12 18 7/31 8 7/31 9 15 15 24 25 28 26 28 31 30 29 33 32 30 31 34 40 43))))
然后检索此列表。
要保存数据,我使用例程:
(defun rol:SalvaListaSPTsEmArquivo (rolSalvaGandeLista / caminhoComppleto diretorio nomeArquivoCargas TargetFile ) (setq caminhoComppleto (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname)))) ;;pega o caminho completo do arquivo do autocad em que estamos trabalhando(setq diretorio (vl-filename-directory caminhoComppleto)) ;;pega apenas o diretorio(setq nomeArquivoCargas (strcat diretorio "\" "Sondagens.crg"))(setq TargetFile (open nomeArquivoCargas "w")) ;;open file to write(princ rolSalvaGandeLista TargetFile) ;;record the list into file(close TargetFile) ;;close the file(princ))
要从我使用的列表中检索文件:
(defun rol:LeListaSPTsEmArquivo ( / caminhoComppleto diretorio nomeArquivoCargas TargetFile retorno ) (setq caminhoComppleto (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname)))) ;;pega o caminho completo do arquivo do autocad em que estamos trabalhando(setq diretorio (vl-filename-directory caminhoComppleto)) ;;pega apenas o diretorio(setq nomeArquivoCargas (strcat diretorio "\" "Sondagens.crg"))(setq TargetFile (open nomeArquivoCargas "r")) ;;open file to write(setq retorno (read-line TargetFile) )(close TargetFile) ;;close the fileretorno)
然后我需要用从文件中读取的值作为图像来完成两个列表框:
为此,我使用以下代码:
;;============================== (or *Make* (setq *Make* "0")) (or *Model* (setq *Model* "0")) ;;============================== ;;============================== (setq theListFromFile (read (rol:LeListaSPTsEmArquivo) ) ) ;;evaluate the string into a list (setq DataCabecalhoSondagem (nth 0 theListFromFile) ) (setq DataSondagens (nth 1 theListFromFile) ) ;;============================== ;;==============================(start_list "list" 3)(mapcar '(lambda (var) (add_list (LM:lst->str (car var) "\t" ) ))DataSondagens)(end_list) ;;============================== ;;============================== (set_tile "list" *Make*) (UpdateList "listSpts" (cadr (nth (atoi *Make*) DataSondagens))) (set_tile "listSpts" *Model*) ;;=============================
但是,如果每个值列表都在引号中,我只能用保存在文件中的值填充两个列表框,例如:
(("Nome da Obra" "Nome do Cliente" "RSP007-2016" "Rua sem nome s/n") (((“SPT01” “0.11” “1.15”) (“1/35” “3/33” “4/31” “1” “18” “7/31” “8” “7/31” “9” “15” “15” “24” “25” “28” “26” “28” “31” “30” “29” “33” “32” “30” “31” “34” “40” “43”)) ((“SPT02” “0.22” “2.15”) (“2/35” “3/33” “4/31” “2” “18” “7/31” “8” “7/31” “9” “15” “15” “24” “25” “28” “26” “28” “31” “30” “29” “33” “32” “30” “31” “34” “40” “43”))…)
所以我需要更改rol:salvalistapsptsemarquivo例程,将每个列表值记录在引号中,但我无法做到这一点
我用的是Mac Lee的代码片段,顺便说一句,非常好。
有人能帮我吗?