|
发表于 2002-7-22 16:06:00
|
显示全部楼层
程序是写完了,但实现的办法太笨拙了吧?
(defun c:nnn()
(setq a "C:\\MyFolder\\MyFile.txt")
(setq kk (JustFName a))
(setq l (strlen kk))
(setq ll (- l 4))
(setq st (substr kk 1 ll))
(setq dri (strcat "md " "f:\\mm\\" st))
(md))
(defun JustFName (cFileName / bsLoc ColonLoc)
;; Check for BackSlash
(setq bsLoc (rat "\\" cfileName))
(if (> bsLoc 0)
(substr cFilename (1+ bsLoc))
(progn
;; 检查盘号 ":"
(setq ColonLoc (rat ":" cfileName))
(if (> ColonLoc 0)
(substr cFilename (1+ ColonLoc))
cFileName
) ;_ end of if
) ;_ end of progn
) ;_ end of if
) ;_ end of defun
;;;==================================================================
;;; (Rat cSearchExpression cExpressionSearched)
;;; 返回指定字符串出现在另一字符串最右边的位置的数字。
;;;------------------------------------------------------------------
;;; 参数:
;;; cSearchExpression [STR] - 要搜索的字符串
;;; cExpressionSearched [STR] - 被搜索的字符串
;;;------------------------------------------------------------------
;;; 返回:
;;; [INT] - 字符串的位置
;;; 示例: (setq a "A Lot of Text.")
;;; (Rat "Text" a) ; 返回 10
;;;------------------------------------------------------------------
(defun Rat (cSearch cSearchIn / return SearchFor cont n)
;; 避开特殊字符
(cond
(
(= cSearch "\\")
(setq SearchFor "*`\\*")
)
(
(= cSearch ".")
(setq SearchFor "*`.*")
)
(
(= cSearch "#")
(setq SearchFor "*`#*")
)
(
(= cSearch "*")
(setq SearchFor "*`**")
)
(
(= cSearch "~")
(setq SearchFor "*`~*")
)
(
(= cSearch "-")
(setq SearchFor "*`-*")
)
(
(= cSearch ",")
(setq SearchFor "*`,*")
)
(
(= cSearch "`")
(setq SearchFor "*``*")
)
(
T
(setq SearchFor (strcat "*" cSearch "*"))
)
) ;_ end of cond
(cond
(
;; 确定是否匹配
(not (wcmatch cSearchIn SearchFor))
(setq return 0)
)
(
T
(setq n (strlen cSearchIn))
(setq TestStr (substr cSearchIn n))
(setq cont T)
(while Cont
(if (wcmatch TestStr SearchFor)
(progn
(setq Cont nil)
(setq return n)
) ;_ end of progn
(progn
(setq n (1- n))
(setq TestStr (substr cSearchIn n)) ) ;_ end of progn
) ;_ end of if
) ;_ end of while
)
) ;_ end of cond
return
) ;_ end of defun
(defun md()
(command "sh" dri)
) |
|