明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: 荒野孤行

[源码] 自制工具箱的自定义快捷键程序

[复制链接]
发表于 2014-6-10 22:15:25 | 显示全部楼层
我的还没完。。Z版已经完成。。。
  1. ;;;*****自定义快捷命令 程序********
  2. (defun sk_mapcar(fun lst)
  3.   (mapcar '(lambda(x) (fun (car x)(cdr x))) lst)
  4.   )
  5. (defun onekeyset (/ lst)  ;一键设置
  6.   (purgeall)  
  7.   (setq lst(list
  8.   (cons "wdy501" "ff")
  9.   (cons "wdy502" "fff")
  10.   (cons "wdy503" "oo")
  11.   (cons "wdy504" "ooo")
  12.   (cons "wdy505" "2o")
  13.   (cons "wdy506" "xx")
  14.   (cons "wdy507" "ns")
  15.   (cons "wdy508" "wk")
  16.   (cons "wdy509" "bra")
  17.   (cons "wdy510" "lj")
  18.   ))
  19.   (sk_mapcar set_tile lst)
  20. )


  21. (defun purgeall (/ lst) ;自定义快捷键全部清除
  22.   (setq lst(list
  23.              (cons "wdy501" "")
  24.   (cons "wdy502" "")
  25.   (cons "wdy503" "")
  26.   (cons "wdy504" "")
  27.   (cons "wdy505" "")
  28.   (cons "wdy506" "")
  29.   (cons "wdy507" "")
  30.   (cons "wdy508" "")
  31.   (cons "wdy509" "")
  32.   (cons "wdy510" "")
  33.              ))
  34.   (sk_mapcar set_tile lst)
  35. )

  36. ;;;***读取注册表 程序开始***
  37. (defun read_from_registry ()
  38.   (setq rfreg_wdy501 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy501"))
  39.   (setq rfreg_wdy502 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy502"))
  40.   (setq rfreg_wdy503 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy503"))
  41.   (setq rfreg_wdy504 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy504"))
  42.   (setq rfreg_wdy505 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy505"))
  43.   (setq rfreg_wdy506 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy506"))
  44.   (setq rfreg_wdy507 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy507"))
  45.   (setq rfreg_wdy508 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy508"))
  46.   (setq rfreg_wdy509 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy509"))
  47.   (setq rfreg_wdy510 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy510"))
  48. )
  49. ;;;***读取注册表 程序结束***

  50. ;;;*****写入WDY 程序开始*****
  51. (defun write_to_wdy ()
  52.   (if rfreg_wdy501 (set_tile "wdy501" rfreg_wdy501) (set_tile "wdy501" ""))
  53.   (if rfreg_wdy502 (set_tile "wdy502" rfreg_wdy502) (set_tile "wdy502" ""))
  54.   (if rfreg_wdy503 (set_tile "wdy503" rfreg_wdy503) (set_tile "wdy503" ""))
  55.   (if rfreg_wdy504 (set_tile "wdy504" rfreg_wdy504) (set_tile "wdy504" ""))
  56.   (if rfreg_wdy505 (set_tile "wdy505" rfreg_wdy505) (set_tile "wdy505" ""))
  57.   (if rfreg_wdy506 (set_tile "wdy506" rfreg_wdy506) (set_tile "wdy506" ""))
  58.   (if rfreg_wdy507 (set_tile "wdy507" rfreg_wdy507) (set_tile "wdy507" ""))
  59.   (if rfreg_wdy508 (set_tile "wdy508" rfreg_wdy508) (set_tile "wdy508" ""))
  60.   (if rfreg_wdy509 (set_tile "wdy509" rfreg_wdy509) (set_tile "wdy509" ""))
  61.   (if rfreg_wdy510 (set_tile "wdy510" rfreg_wdy510) (set_tile "wdy510" ""))
  62. )
  63. ;;;*****写入WDY 程序结束*****

  64. ;;;*****读取WDY 程序开始*****
  65. (defun read_from_wdy (/ lst)
  66.   (setq lst(list
  67.              (cons rfw_wdy501 "wdy501")
  68.              (cons rfw_wdy502 "wdy502")
  69.              (cons rfw_wdy503 "wdy503")
  70.              ))
  71.   (sk_mapcar get_tile lst)

  72. ;;;  (setq rfw_wdy501 (get_tile "wdy501"))
  73. ;;;  (setq rfw_wdy502 (get_tile "wdy502"))
  74. ;;;  (setq rfw_wdy503 (get_tile "wdy503"))
  75. ;;;  (setq rfw_wdy504 (get_tile "wdy504"))
  76. ;;;  (setq rfw_wdy505 (get_tile "wdy505"))
  77. ;;;  (setq rfw_wdy506 (get_tile "wdy506"))
  78. ;;;  (setq rfw_wdy507 (get_tile "wdy507"))
  79. ;;;  (setq rfw_wdy508 (get_tile "wdy508"))
  80. ;;;  (setq rfw_wdy509 (get_tile "wdy509"))
  81. ;;;  (setq rfw_wdy510 (get_tile "wdy510"))
  82. )
  83. ;;;*****读取WDY 程序结束*****

  84. ;;;***写入注册表 程序开始
  85. (defun write_to_registry (/ lst)
  86.   (defun sk_reg_write(sk_name sk_value)(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" sk_name sk_value))
  87.   (setq lst(list
  88.              (cons "wdy501" rfw_wdy501)
  89.              (cons "wdy502" rfw_wdy502)
  90.              (cons "wdy503" rfw_wdy503)
  91.              ))
  92. (sk_mapcar sk_reg_write lst)
  93. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy501" rfw_wdy501)
  94. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy502" rfw_wdy502)
  95. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy503" rfw_wdy503)
  96. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy504" rfw_wdy504)
  97. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy505" rfw_wdy505)
  98. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy506" rfw_wdy506)
  99. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy507" rfw_wdy507)
  100. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy508" rfw_wdy508)
  101. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy509" rfw_wdy509)
  102. ;;;(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy510" rfw_wdy510)
  103. )
  104. ;;;***写入注册表 程序结束

  105. ;;;***自定义命令 程序开始***
  106. (defun wdy_qidong (/ lst)
  107.   (read_from_registry)
  108.   (setq lst(list
  109.              (cons rfreg_wdy501 "wdy_lxdj")
  110.              (cons rfreg_wdy502 "wdy_kxyj")
  111.              (cons rfreg_wdy503 "wdy_sxpy")
  112.              ))
  113.   (defun sk_eval(sk_cmd fun_)(eval (read (strcat "(defun c:" sk_cmd "() (c:" fun_ "))"))))
  114.   (sk_mapcar sk_eval lst)
  115. ;;;  
  116. ;;;  (if rfreg_wdy501 (eval (read (strcat "(defun c:" rfreg_wdy501 "() (c:wdy_lxdj))")))) ;rfreg_wdy501对应于wdy_lxdj命令,后面的也一样
  117. ;;;  (if rfreg_wdy502 (eval (read (strcat "(defun c:" rfreg_wdy502 "() (c:wdy_kxyj))"))))
  118. ;;;  (if rfreg_wdy503 (eval (read (strcat "(defun c:" rfreg_wdy503 "() (c:wdy_sxpy))"))))
  119. ;;;  (if rfreg_wdy504 (eval (read (strcat "(defun c:" rfreg_wdy504 "() (c:wdy_dcpy))"))))
  120. ;;;  (if rfreg_wdy505 (eval (read (strcat "(defun c:" rfreg_wdy505 "() (c:wdy_ecpy))"))))
  121. ;;;  (if rfreg_wdy506 (eval (read (strcat "(defun c:" rfreg_wdy506 "() (c:wdy_cjxj))"))))
  122. ;;;  (if rfreg_wdy507 (eval (read (strcat "(defun c:" rfreg_wdy507 "() (c:wdy_nspy))"))))
  123. ;;;  (if rfreg_wdy508 (eval (read (strcat "(defun c:" rfreg_wdy508 "() (c:wdy_wkpy))"))))
  124. ;;;  (if rfreg_wdy509 (eval (read (strcat "(defun c:" rfreg_wdy509 "() (c:wdy_jddk))"))))
  125. ;;;  (if rfreg_wdy510 (eval (read (strcat "(defun c:" rfreg_wdy510 "() (c:wdy_dxhy))"))))
  126. )
发表于 2014-6-10 21:51:59 | 显示全部楼层
  1. ;;;*****自定义快捷命令 程序********
  2. (defun onekeyset ()  ;一键设置
  3. (mapcar 'set_tile
  4. '("wdy501" "wdy502" "wdy503" "wdy504" "wdy505" "wdy506" "wdy507" "wdy508" "wdy509" "wdy510")
  5. '("ff" "fff" "oo" "ooo" "2o" "xx" "ns" "wk" "bra" "lj")
  6. )
  7. )
  8. (defun purgeall () ;自定义快捷键全部清除
  9. (mapcar 'set_tile
  10. '("wdy501" "wdy502" "wdy503" "wdy504" "wdy505" "wdy506" "wdy507" "wdy508" "wdy509" "wdy510")
  11. '("" "" "" "" "" "" "" "" "" "")
  12. )
  13. )
  14. ;;;***读取注册表 程序开始***
  15. (defun read_from_registry ()
  16. (foreach x
  17. '("wdy501" "wdy502" "wdy503" "wdy504" "wdy505" "wdy506" "wdy507" "wdy508" "wdy509" "wdy510")
  18. (setq a (read(strcat "rfreg_" x)))
  19. (set a (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" x))
  20. )
  21. )
  22. ;;;***读取注册表 程序结束***
  23. ;;;*****写入WDY 程序开始*****
  24. (defun write_to_wdy ()
  25. (foreach x
  26. '("wdy501" "wdy502" "wdy503" "wdy504" "wdy505" "wdy506" "wdy507" "wdy508" "wdy509" "wdy510")
  27. (setq a (eval(read(strcat "rfreg_" x))))
  28. (set_tile x (if a a ""))
  29. )
  30. )
  31. ;;;*****写入WDY 程序结束*****
  32. ;;;*****读取WDY 程序开始*****
  33. (defun read_from_wdy ()
  34. (foreach x
  35. '("wdy501" "wdy502" "wdy503" "wdy504" "wdy505" "wdy506" "wdy507" "wdy508" "wdy509" "wdy510")
  36. (set (read(strcat "rfw_" x)) (get_tile x))
  37. )
  38. )
  39. ;;;*****读取WDY 程序结束*****
  40. ;;;***写入注册表 程序开始
  41. (defun write_to_registry ()
  42. (foreach x
  43. '("wdy501" "wdy502" "wdy503" "wdy504" "wdy505" "wdy506" "wdy507" "wdy508" "wdy509" "wdy510")
  44. (vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" x (read(strcat "rfw_" x)))
  45. )
  46. )
  47. ;;;***写入注册表 程序结束
  48. ;;;***自定义命令 程序开始***
  49. (defun wdy_qidong ()
  50.   (read_from_registry)
  51. (mapcar
  52. '(lambda (x y)
  53. (setq a (eval(read(strcat "rfreg_" x))))
  54. (if a (eval(read(strcat "(defun c:" a "() (c:wdy_" y "))"))))
  55. )
  56. '("wdy501" "wdy502" "wdy503" "wdy504" "wdy505" "wdy506" "wdy507" "wdy508" "wdy509" "wdy510")
  57. '('"lxdj" "kxyj" "sxpy" "dcpy" "ecpy" "cjxj" "nspy" "wkpy" "jddk" "dxhy")
  58. )
  59. )
 楼主| 发表于 2014-6-10 19:41:11 | 显示全部楼层
edata 发表于 2014-6-10 10:07
应该是工具箱之类的,个人觉得应该采用一个包含点对的表来制作,因为需要一一对应,不然多了容易出错,也不 ...

采用cons和car、cadr去做么?用了大家写的,没达到想要的效果,我的源码已经丢出来了。
 楼主| 发表于 2014-6-10 19:40:04 | 显示全部楼层
ll_j 发表于 2014-6-10 09:18
实话实说,没想出楼主到底是在什么情况下使用,在我的一个帖子里提到过类似的“变态”定义,不过我还是认为 ...

用于自定义命令的快捷键设置,想进行优化,相关的源码已经发到帖子里面了。
 楼主| 发表于 2014-6-10 19:38:17 | 显示全部楼层
ZZXXQQ 发表于 2014-6-10 08:08
首先变量reg_wdy50?中要有需要的东东。

这是我做的WDY工具箱里面自定义快捷键的源码程序,那样写的太多了,我希望通过mapcar函数进行优化。

;;;*****自定义快捷命令 程序********
(defun onekeyset ()  ;一键设置
  (purgeall)
  (set_tile "wdy501" "ff")
  (set_tile "wdy502" "fff")
  (set_tile "wdy503" "oo")
  (set_tile "wdy504" "ooo")
  (set_tile "wdy505" "2o")
  (set_tile "wdy506" "xx")
  (set_tile "wdy507" "ns")
  (set_tile "wdy508" "wk")
  (set_tile "wdy509" "bra")
  (set_tile "wdy510" "lj")
)

(defun purgeall () ;自定义快捷键全部清除
  (set_tile "wdy501" "")
  (set_tile "wdy502" "")
  (set_tile "wdy503" "")
  (set_tile "wdy504" "")
  (set_tile "wdy505" "")
  (set_tile "wdy506" "")
  (set_tile "wdy507" "")
  (set_tile "wdy508" "")
  (set_tile "wdy509" "")
  (set_tile "wdy510" "")
)

;;;***读取注册表 程序开始***
(defun read_from_registry ()
  (setq rfreg_wdy501 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy501"))
  (setq rfreg_wdy502 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy502"))
  (setq rfreg_wdy503 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy503"))
  (setq rfreg_wdy504 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy504"))
  (setq rfreg_wdy505 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy505"))
  (setq rfreg_wdy506 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy506"))
  (setq rfreg_wdy507 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy507"))
  (setq rfreg_wdy508 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy508"))
  (setq rfreg_wdy509 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy509"))
  (setq rfreg_wdy510 (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy510"))
)
;;;***读取注册表 程序结束***

;;;*****写入WDY 程序开始*****
(defun write_to_wdy ()
  (if rfreg_wdy501 (set_tile "wdy501" rfreg_wdy501) (set_tile "wdy501" ""))
  (if rfreg_wdy502 (set_tile "wdy502" rfreg_wdy502) (set_tile "wdy502" ""))
  (if rfreg_wdy503 (set_tile "wdy503" rfreg_wdy503) (set_tile "wdy503" ""))
  (if rfreg_wdy504 (set_tile "wdy504" rfreg_wdy504) (set_tile "wdy504" ""))
  (if rfreg_wdy505 (set_tile "wdy505" rfreg_wdy505) (set_tile "wdy505" ""))
  (if rfreg_wdy506 (set_tile "wdy506" rfreg_wdy506) (set_tile "wdy506" ""))
  (if rfreg_wdy507 (set_tile "wdy507" rfreg_wdy507) (set_tile "wdy507" ""))
  (if rfreg_wdy508 (set_tile "wdy508" rfreg_wdy508) (set_tile "wdy508" ""))
  (if rfreg_wdy509 (set_tile "wdy509" rfreg_wdy509) (set_tile "wdy509" ""))
  (if rfreg_wdy510 (set_tile "wdy510" rfreg_wdy510) (set_tile "wdy510" ""))
)
;;;*****写入WDY 程序结束*****

;;;*****读取WDY 程序开始*****
(defun read_from_wdy ()
  (setq rfw_wdy501 (get_tile "wdy501"))
  (setq rfw_wdy502 (get_tile "wdy502"))
  (setq rfw_wdy503 (get_tile "wdy503"))
  (setq rfw_wdy504 (get_tile "wdy504"))
  (setq rfw_wdy505 (get_tile "wdy505"))
  (setq rfw_wdy506 (get_tile "wdy506"))
  (setq rfw_wdy507 (get_tile "wdy507"))
  (setq rfw_wdy508 (get_tile "wdy508"))
  (setq rfw_wdy509 (get_tile "wdy509"))
  (setq rfw_wdy510 (get_tile "wdy510"))
)
;;;*****读取WDY 程序结束*****

;;;***写入注册表 程序开始
(defun write_to_registry ()
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy501" rfw_wdy501)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy502" rfw_wdy502)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy503" rfw_wdy503)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy504" rfw_wdy504)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy505" rfw_wdy505)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy506" rfw_wdy506)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy507" rfw_wdy507)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy508" rfw_wdy508)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy509" rfw_wdy509)
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\WDYGJX\\Hotkey" "wdy510" rfw_wdy510)
)
;;;***写入注册表 程序结束

;;;***自定义命令 程序开始***
(defun wdy_qidong ()
  (read_from_registry)
  (if rfreg_wdy501 (eval (read (strcat "(defun c:" rfreg_wdy501 "() (c:wdy_lxdj))")))) ;rfreg_wdy501对应于wdy_lxdj命令,后面的也一样
  (if rfreg_wdy502 (eval (read (strcat "(defun c:" rfreg_wdy502 "() (c:wdy_kxyj))"))))
  (if rfreg_wdy503 (eval (read (strcat "(defun c:" rfreg_wdy503 "() (c:wdy_sxpy))"))))
  (if rfreg_wdy504 (eval (read (strcat "(defun c:" rfreg_wdy504 "() (c:wdy_dcpy))"))))
  (if rfreg_wdy505 (eval (read (strcat "(defun c:" rfreg_wdy505 "() (c:wdy_ecpy))"))))
  (if rfreg_wdy506 (eval (read (strcat "(defun c:" rfreg_wdy506 "() (c:wdy_cjxj))"))))
  (if rfreg_wdy507 (eval (read (strcat "(defun c:" rfreg_wdy507 "() (c:wdy_nspy))"))))
  (if rfreg_wdy508 (eval (read (strcat "(defun c:" rfreg_wdy508 "() (c:wdy_wkpy))"))))
  (if rfreg_wdy509 (eval (read (strcat "(defun c:" rfreg_wdy509 "() (c:wdy_jddk))"))))
  (if rfreg_wdy510 (eval (read (strcat "(defun c:" rfreg_wdy510 "() (c:wdy_dxhy))"))))
)
发表于 2014-6-10 13:55:30 | 显示全部楼层
本帖最后由 llsheng_73 于 2014-6-10 14:09 编辑

  1. (defun tt(lst)
  2.   (mapcar'(lambda(x)(eval(read(strcat"(defun c:"(vl-princ-to-string(car x))"()("(vl-princ-to-string(last x))"))"))))lst)
  3.   )
  4. (defun tt1(lst)
  5.   (foreach x lst(eval(read(strcat"(defun c:"(vl-princ-to-string(car x))"()("(vl-princ-to-string(last x))"))")))))

;(tt'((reg_wdy501 wdy_zf)(reg_wdy502 wdy_ff)(reg_wdy503 wdy_py)(reg_wdy504 wdy_sy)(reg_wdy505 wdy_yy)))
;(tt1'((reg_wdy501 wdy_zf)(reg_wdy502 wdy_ff)(reg_wdy503 wdy_py)(reg_wdy504 wdy_sy)(reg_wdy505 wdy_yy)))

另外多线段绘制,可指定各点起止宽度,可指定不为0的凸度
http://bbs.mjtd.com/forum.php?mo ... &fromuid=202795
里边子函数 x的定义个人觉得还是可以参考一下的,当然,实际意义不大,与楼主的需求也不相关....
唯一的好处是提前根据参数的类型定义出了对应的处理过程而不需要在循环内部重复判断该参数类型去调用相应的处理函数
发表于 2014-6-10 10:07:15 | 显示全部楼层
应该是工具箱之类的,个人觉得应该采用一个包含点对的表来制作,因为需要一一对应,不然多了容易出错,也不好添加。
发表于 2014-6-10 09:18:41 | 显示全部楼层
实话实说,没想出楼主到底是在什么情况下使用,在我的一个帖子里提到过类似的“变态”定义,不过我还是认为理论上是可行的,并没有什么实用价值。
楼主的wd*和reg_wd*是什么关系?这么复杂的变量名和变量的值又是什么关系?仅仅从mapcar的使用来说,总是不难的,不过我感觉应该有更深层次的优化才对。
发表于 2014-6-10 09:03:46 | 显示全部楼层
(setq lst1 '(wdy501 wdy502 wdy503 wdy504 wdy505))
(setq lst2 '(wdy_zf wdy_ff wdy_py wdy_sy wdy_yy))


(mapcar
  '(lambda (x y)
     (if (= (type
              (setq m (eval (read (strcat "reg_" (VL-PRINC-TO-STRING x)))))
            )
            'STR
         )
       (set (read (strcat "c:" m)) y)
     )
   )
  lst1
  lst2
)
发表于 2014-6-10 08:08:46 | 显示全部楼层
首先变量reg_wdy50?中要有需要的东东。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-12-23 13:55 , Processed in 0.173318 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表