马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
XDRX API 从 2017.1215版本,提供SHELL扩展给LISP,例子如下,关于SHELL可以做什么,可以百度。
SHELL函数:xdrx_shell_open
xdrx_shell_readdata
xdrx_shell_writedata
xdrx_shell_close
xdrx_shell_getlasterror
- ;;; Test 2
- ;;; 改变目录到 D盘的drivers目录, 获取目录
- ;;; 列表并打印到AUTOCAD命令行
- ;;; 如何使用 && 和命令的组合的例子。
- (defun c:test2 (/ handle sResult)
- (setq handle (xdrx_shell_open "c:\\windows\\system32\\cmd.exe"
- "/c d: && cd \\drivers\\ && dir"
- )
- )
- (if (/= nil handle)
- (progn
- (while (/= nil (setq sResult (xdrx_shell_readdata handle)))
- (princ sResult)
- )
- (xdrx_shell_close handle)
- )
- )
- (princ)
- )
- ;;; test 3
- ;;; 改变目录到 D盘的drivers目录, 获取目录
- ;;; 列表并打印到AUTOCAD命令行
- ;;; 如何使用管道和 && 和命令的组合的例子。
- (defun c:test3 (/ handle sResult)
- (setq handle (xdrx_shell_open "c:\\windows\\system32\\cmd.exe"
- "/c d: && cd \\drivers\\ && dir | sort"
- )
- )
- (if (/= nil handle)
- (progn
- (while (/= nil (setq sResult (xdrx_shell_readdata handle)))
- (princ sResult)
- )
- (xdrx_shell_close handle)
- )
- )
- (princ)
- )
- (defun c:test4 (/ handle sResult sContents)
- (setq handle (xdrx_shell_open "c:\\windows\\system32\\cmd.exe"
- "/c type \\Windows\\system.ini"
- )
- )
- (if (/= nil handle)
- (progn
- (setq sContents "")
- (while (/= nil (setq sResult (xdrx_shell_readdata handle)))
- (setq sContents (strcat sContents sResult))
- )
- (xdrx_shell_close handle)
- )
- )
- (princ sContents)
- (princ)
- )
- ;;; Opens cmd.exe shell using the envirnment variable %comspec% if set.
- ;;; The sort program is run and input is provided via the xdrx_shell_writedata
- ;;; function. This test provides a single string with carriage seperating
- ;;; the words of the input. This is one way to provide line buffered input.
- (defun c:Test5 (/ handle sResult)
- (setq handle (xdrx_shell_open "%comspec%" "/c sort"))
- (if (/= nil handle)
- (progn
- (xdrx_shell_writedata handle "There\nis\na\nfly\n")
- (setq sResult (xdrx_shell_readdata handle))
- (if (/= nil sResult)
- (princ sResult)
- )
- )
- (xdrx_shell_close handle)
- )
- (princ)
- )
- ;;; Opens cmd.exe shell using the envirnment variable %comspec% if set.
- ;;; The sort program is run and input is provided to it through xdrx_shell_writedata
- ;;; by calling it multiple times.
- (defun c:Test6 (/ aList handl sResult)
- (setq aList (list "Lost" "in" "the" "swamp" "with" "the" "gaters"))
- (setq handle (xdrx_shell_open "%comspec%" "/c sort"))
- (if (/= nil handle)
- (progn
- (foreach s aList (xdrx_shell_writedata handle (strcat s "\n")))
- (setq sResult (xdrx_shell_readdata handle))
- (if (/= nil sResult)
- (princ sResult)
- )
- )
- (xdrx_shell_close handle)
- )
- (princ)
- )
|