(setq DwgDir "D:\\tangent\\TwtT20V3\\sys18x64\\")
(split DwgDir "\\")
===>
("D:" "tangent" "TwtT20V3" "sys18x64" "")
=================
http://www.cadtutor.net/forum/sh ... -Based-on-Delimiter
- ;; Usage: (split (getenv "ACADPrefix") ";")
- (defun split (sExpression sDelimiter / len val sList)
- ; Get the length of the first item from the expression based
- ; on delimiter position
- (setq len (vl-string-position (ascii sDelimiter) sExpression))
- ; Loop until there are no more instances of the delimiter
- ; in the expression
- (while (numberp len)
- ; Get the item from the expression
- (setq val (substr sExpression 1 len))
- ; Append the item to the list
- (setq sList (cons val sList))
- ; Get the remaining part of the expression
- (setq sExpression (substr sExpression (+ 2 len)))
- ; Get the length of the next item from the string based
- ; on delimiter position
- (setq len (vl-string-position (ascii sDelimiter) sExpression))
- )
- ; Add the last value to the list
- (if (/= sExpression nil)
- (setq sList (cons sExpression sList))
- )
- ; Reverses the elements in the list and return the list
- (reverse sList)
- )
|