马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [FONT=courier new]
- ;;; ==================================================================
- ;;; 类似acet-str-format
- (defun th-str-format (str newstrlst / n oldstr oldstrlst)
- (setq n 0)
- (setq oldstrlst (mapcar
- (function (lambda (x)
- (setq n (1+ n)
- oldstr (strcat "$" (rtos n 2 0) "#")
- )
- )
- )
- newstrlst
- )
- )
- (mapcar
- (function (lambda (a b)
- (setq str (th-str-repl a b str))
- )
- )
- oldstrlst
- newstrlst
- )
- str
- )
- ;;; 测试
- ;;; 命令: (th-str-format "\ncollecting all $1# objects on layer $2#..."
- ;;; (list "12"
- ;;; "23"))"\ncollecting all 12 objects on layer 23..."
- ;;; 命令: (th-str-format "\ncollecting all $1# objects on layer $2#..."
- ;;; (list "12"
- ;;; "23" "45"))
- ;;; "\ncollecting all 12 objects on layer 23..."
- ;;; 命令: (th-str-format "\ncollecting all $1# ob$1#jects on layer $2#..."
- ;;; (list "12"
- ;;; "23"))
- ;;; "\ncollecting all 12 ob12jects on layer 23..."
- ;;; 命令: (th-str-format "\ncollecting all $1# objects $3#on layer $2#..."
- ;;; (list "12"
- ;;; "23" "ab"))
- ;;; "\ncollecting all 12 objects abon layer 23..."
- ;;; ==================================================================
- (defun th-str-repl (curchar newchar str)
- (while (vl-string-search curchar str)
- (setq str (vl-string-subst newchar curchar str))
- )
- str
- )
- ;;; ==================================================================
- [/FONT]
|