 - (defun parse9 (str delim / I S STR1 STRLST)
- (setq i 0 str1 "")
- (while (/= "" (setq s (substr str (setq i (1+ i)) 1)))
- (cond ((/= delim s) (setq str1 (strcat str1 s)))
- (T (setq strlst (append strlst (list str1)) str1 ""))
- )
- )
- (if (/= str1 "")
- (append strlst (list str1))
- strlst
- )
- )
- (defun sk_str->delim(txt / a nlst B C D K)
- (vl-load-com)
- (if (or (wcmatch txt "*-*")(wcmatch txt "*+*"))
- (progn
- (setq txt(parse9 txt "+") nlst '())
- (while(setq a(car txt))
- (if (wcmatch a "*-*")
- (progn
- (setq b(parse9 a "-"))
- (mapcar 'set '(c d)(list (atoi(car b)) (atoi(cadr b))))
- (setq k (- (min c d) 1))
- (repeat(if(< c d)(1+(- d c))(1+(- c d)))
- (setq nlst(cons (setq k(1+ k)) nlst))
- )
- )
- (setq nlst(cons (atoi a) nlst))
- )
- (setq txt (cdr txt))
- )
- (setq nlst(vl-sort nlst '<)
- nlst(mapcar 'itoa nlst))
- )
- )
- )
- ;;测试程序
- (defun c:tt()
- (setq txt "86+0-60")
- (sk_str->delim txt)
- )
|