本帖最后由 czcxxx 于 2015-9-30 13:08 编辑
主程序正常运行,能获得想要的值,但改为子函数后返回值为NIL
当作主程序时的代码如下:- (defun bat_la (ss_mod ii / x)
- (mapcar
- '(lambda (x) (cdr (assoc ii (entget x))))
- (vl-remove-if
- 'listp
- (mapcar 'cadr (ssnamex ss_mod))
- )
- )
- );;;;取关联表单项值
- (PRINT "\n请选择两个具有部分相同内容的单行文字:")
- (setq ss1 (ssget '((0 . "text"))))
- (WHILE (/= (sslength ss1) 2)
- (PRINT "\n请选择两个具有部分相同内容的单行文字:")
- (setq ss1 (ssget '((0 . "text"))))
- )
- (setq tl_t (bat_la ss1 1))
- (setq pos1 (getint "\n请选择相同内容的起始位置:<0>"))
- (if (null pos1)
- (setq pos1 0)
- )
- (setq str1 (car tl_t))
- (if (setq leng1 (vl-string-mismatch str1 (cadr tl_t) pos1 pos1 t))
- (setq strsub (substr str1 (+ 1 pos1) leng1))
- (setq sstr (strcat "*" strsub "*"))
- )
- (setq sstr sstr)
sstr的值正常可得
当将主程序改为子函数后,再调用返回值为NIL
将主程序改为子函数并调用的代码如下:- (defun bat_la (ss_mod ii / x)
- (mapcar
- '(lambda (x) (cdr (assoc ii (entget x))))
- (vl-remove-if
- 'listp
- (mapcar 'cadr (ssnamex ss_mod))
- )
- )
- );;;;取关联表单项值
- (defun czc_eqt ( / ss1 tl_t pos1 str1 leng1 strsub sstr)
- (PRINT "\n请选择两个具有部分相同内容的单行文字:")
- (setq ss1 (ssget '((0 . "text"))))
- (WHILE (/= (sslength ss1) 2)
- (PRINT "\n请选择两个具有部分相同内容的单行文字:")
- (setq ss1 (ssget '((0 . "text"))))
- )
- (setq tl_t (bat_la ss1 1))
- (setq pos1 (getint "\n请选择相同内容的起始位置:<0>"))
- (if (null pos1)
- (setq pos1 0)
- )
- (setq str1 (car tl_t))
- (if (setq leng1 (vl-string-mismatch str1 (cadr tl_t) pos1 pos1 t))
- (setq strsub (substr str1 (+ 1 pos1) leng1))
- (setq sstr (strcat "*" strsub "*"))
- )
- (setq sstr sstr)
- )
- (czc_eqt)
返回值为NIL,想不明白!!!
请高手给看看!!
谢谢!! |