[原创]系统变量监视器
本帖最后由 作者 于 2008-12-25 10:49:07 编辑;|
;;;系统变量监视器v1.0by xshrimp 2008.12.18
|;
(vl-load-reactors)
(defun gps->sysvar-Changed (a b)
(if (cadr b)(setq sysnew (cons (car b) (getvar (car b)))))
(if
(and
(equal (car sysnew)(car sysold))
(not (equal(cdr sysnew)(cdr sysold)))
)
(progn
(mapcar
'princ
(list "\n系统变量【 "(car sysold)" 】从值 〖"(cdr sysold)" 〗变到〖 "(cdr sysnew)" 〗")
)
(if (not (assoc (car sysold) sysresetlst))
(setq sysresetlst (append sysresetlst (list sysold)))
)
(setq sysold nil)
)
)
(prin1)
)
(defun gps->sysvar-WillChange (a b)
(if (car b)(setq sysold (cons(car b) (getvar (car b)))))
(prin1)
)
(defun sysvar-reactor:start()
(setq sysresetlst nil)
(vlr-sysvar-reactor nil '((:vlr-sysVarChanged .gps->sysvar-Changed )))
(vlr-sysvar-reactor nil '((:vlr-sysVarWillChange.gps->sysvar-WillChange)))
(prin1)
)
(defun c:sys( / ukw x)
(defun sysvar-reactor:stop()
(vlr-remove-all :vlr-sysvar-reactor)
(prin1)
)
(defun sysvar-reactor:reset(/ msg)
(mapcar
'(lambda (x)
(setq msg (vl-catch-all-apply 'setvar (list (car x) (cdr x))))
(if (vl-catch-all-error-p msg )
(princ (strcat "\n" (vl-catch-all-error-message msg)))
(mapcar
'princ
(list "\n系统变量【 " (car x) " 】恢复到 〖" (cdr x) " 〗")
)
)
)
sysresetlst
)
)
(INITGET 2 "S T R")
(setq ukw (GETKWORD"\n系统变量监视器[启动(S)/停止(T)/恢复系统变量至监视前(R)]"))
(cond
((= "S" ukw)(sysvar-reactor:start))
((= "R" ukw)(sysvar-reactor:stop)(sysvar-reactor:reset))
(T (sysvar-reactor:stop))
)
(prin1)
)
(sysvar-reactor:start)
(princ"\nshlisp.ys168.com xshrimp 2008.12.18")
(princ "\n系统变量监视器,启动命令 SYS ")
(prin1)
用途::对于加载一些未知程序.监控其修改的系统变量.测试完程序.恢复系统变量. (RO)只读的那种变量能监视吗?例如:cdate
很好的代码,谢谢楼主分享。 好帖子,必须支持顶一波! <p>好啊先下下来看看一下啊</p><p>谢谢楼主!!!!</p> <p>支持一下</p><p>建议增加</p><p class="table_body">:vlr-lispCancelled</p><p class="table_body">在用户ESC非法退出lisp时依然有效</p><p class="table_body">(defun c:test()<br/> (setvar "osmode" 0)<br/> (getpoint)<br/>)</p><p class="table_body">命令: test<br/>系统变量【 OSMODE 】从值 〖15359 〗变到〖 0 〗*取消*<br/>; 错误: 函数被取消<br/>命令:<br/></p> sys 命令可以恢复原先的系统变量值 <p>是个好东西 </p> 楼主果然厉害!受教了 原来这么早就有人发表~
支持源码 楼主的帖子看见就顶。 老大的作品,很强大!! 很感谢楼主的程序,一直想知道units的系统变量,这下终于知道了!
系统变量【 LUPREC 】从值 〖4 〗变到〖 8 〗
多谢了!