本帖最后由 CAD智能@未来 于 2024-9-27 09:35 编辑
- 将文字、数字、字母分解成表
- (CSY:String:Spl “明经CAD论坛”)
- 输出:("明" "经" "C" "A" "D" "论" "坛")
- (CSY:String:Spl2 "明经CAD论坛")
- 输出:("明经" "CAD" "论坛")
复制代码- (defun CSY:String:Spl (str / lst rslt x)
- (setq lst (vl-string->list str))
- (setq rslt nil)
- (while (setq x (car lst))
- (if (<= x 127)
- (setq rslt (cons (vl-list->string (list x)) rslt))
- (progn
- (setq rslt (cons (vl-list->string (list x (cadr lst))) rslt))
- (setq lst (cdr lst))
- )
- )
- (setq lst (cdr lst))
- )
- (reverse rslt)
- )
- (defun CSY:String:Spl2 (str / lst rslt str_lst x mart)
- (setq lst (vl-string->list str))
- (setq str_lst nil)
- (setq rslt nil)
- (if (<= (car lst) 127)
- (setq mart 0)
- (setq mart 1)
- )
- (while (setq x (car lst))
- (cond
- ((and (<= x 127) (= mart 0))
- (setq str_lst (cons x str_lst))
- )
- ((and (<= x 127) (= mart 1))
- (setq rslt (cons (vl-list->string (reverse str_lst)) rslt))
- (setq str_lst (list x))
- (setq mart 0)
- )
- ((and (> x 127) (= mart 0))
- (setq rslt (cons (vl-list->string (reverse str_lst)) rslt))
- (setq str_lst (list x))
- (setq mart 1)
- )
- ((and (> x 127) (= mart 1))
- (setq str_lst (cons x str_lst))
- )
- (t
- )
- )
- (setq lst (cdr lst))
- )
- (reverse (cons (vl-list->string (reverse str_lst)) rslt))
- )
|