乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 77|回复: 1

[编程交流] 再次帮助

[复制链接]

2

主题

2

帖子

0

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:44:03 | 显示全部楼层 |阅读模式
事实上,我需要的是在文本文件中保存以下格式的列表:
  1. (("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))))

然后检索此列表。
要保存数据,我使用例程:
  1. (defun rol:SalvaListaSPTsEmArquivo (rolSalvaGandeLista / caminhoComppleto diretorio nomeArquivoCargas TargetFile )  
  2. (setq caminhoComppleto (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname)))) ;;pega o caminho completo do arquivo do autocad em que estamos trabalhando
  3. (setq diretorio (vl-filename-directory caminhoComppleto)) ;;pega apenas o diretorio
  4. (setq nomeArquivoCargas (strcat diretorio "\" "Sondagens.crg"))
  5. (setq TargetFile (open nomeArquivoCargas "w")) ;;open file to write
  6. (princ rolSalvaGandeLista TargetFile) ;;record the list into file
  7. (close TargetFile) ;;close the file
  8. (princ)
  9. )

要从我使用的列表中检索文件:
  1. (defun rol:LeListaSPTsEmArquivo ( / caminhoComppleto diretorio nomeArquivoCargas TargetFile retorno )  
  2. (setq caminhoComppleto (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname)))) ;;pega o caminho completo do arquivo do autocad em que estamos trabalhando
  3. (setq diretorio (vl-filename-directory caminhoComppleto)) ;;pega apenas o diretorio
  4. (setq nomeArquivoCargas (strcat diretorio "\" "Sondagens.crg"))
  5. (setq TargetFile (open nomeArquivoCargas "r")) ;;open file to write
  6. (setq retorno (read-line TargetFile) )
  7. (close TargetFile) ;;close the file
  8. retorno
  9. )

然后我需要用从文件中读取的值作为图像来完成两个列表框:

                               
登录/注册后可看大图

 
为此,我使用以下代码:
  1. ;;==============================
  2. (or *Make*  (setq *Make*  "0"))
  3. (or *Model* (setq *Model* "0"))
  4. ;;==============================
  5.   
  6. ;;==============================
  7. (setq theListFromFile (read (rol:LeListaSPTsEmArquivo) ) ) ;;evaluate the string into a list
  8. (setq DataCabecalhoSondagem (nth 0 theListFromFile) )
  9. (setq DataSondagens (nth 1 theListFromFile) )
  10. ;;==============================
  11.   
  12. ;;==============================
  13. (start_list "list" 3)
  14. (mapcar
  15.         '(lambda (var)
  16.                 (add_list
  17.                 (LM:lst->str (car var) "\t" )
  18.         )
  19. )
  20. DataSondagens
  21. )
  22. (end_list)
  23. ;;==============================
  24.   
  25. ;;==============================
  26. (set_tile "list" *Make*)
  27. (UpdateList "listSpts" (cadr (nth (atoi *Make*) DataSondagens)))
  28. (set_tile "listSpts" *Model*)
  29. ;;=============================

 
但是,如果每个值列表都在引号中,我只能用保存在文件中的值填充两个列表框,例如:
  1. (("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的代码片段,顺便说一句,非常好。
有人能帮我吗?
184409nz6sstod6r4eal47.jpg
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-5 19:41:04 | 显示全部楼层
请阅读代码发布指南并编辑您的帖子,将代码包含在代码标签中。[NOPARSE]
  1. Your Code goes here
[/NOPARSE]=
 
  1. Your Code goes here
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 04:16 , Processed in 0.709290 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表