Is there an autolisp function to format the text string conversion of a real?
I need a thousand seperator - space between each group of 3 values left of the decimal.
thx ..
Solved! Go to Solution.
Solved by Ajilal.Vijayan. Go to Solution.
Modified the function found in here
(defun space (n p / a b m i lst) (setq dz (getvar 'dimzin)) (setvar 'Dimzin 0) (setq str (rtos (abs n) 2 p)) (setvar 'Dimzin dz) (setq a (vl-filename-base str) b (substr str (1+ (strlen a))) m (vl-string->list a) i (length m) lst nil) (while (>= i 3) (setq lst (append (list 32 (nth (- i 3) m) (nth (- i 2) m) (nth (1- i) m)) lst ) i ( - i 3)) lst ) (strcat (if (minusp n) "-" "")(substr str 1 i) (vl-list->string (if (zerop i) (cdr lst) lst)) b))
Command: (space 123456789 3) "123 456 789.000"
@pbejse wrote:
@Ajilal.Vijayan wrote:Modified the function found in here....
No wonder the coding looks familiar
Well heck *pbejse* a simple modification to your original and no one will have to create any other versions of your original and you will live forever:
;pbejse - modified ;(DelimTxt 123456789 3 " ") ;(DelimTxt 123456789 3 ",") ;(DelimTxt 123456789 3 " : ") (defun DelimTxt (n p d / dz dl a b m i lst) (setq dl (vl-string->list d)) (setq dz (getvar 'dimzin)) (setvar 'Dimzin 0) (setq str (rtos (abs n) 2 p)) (setvar 'Dimzin dz) (setq a (vl-filename-base str) b (substr str (1+ (strlen a))) m (vl-string->list a) i (length m) lst nil );setq (while (>= i 3) (setq lst (append dl (list (nth (- i 3) m) (nth (- i 2) m) (nth (1- i) m) );list lst);append i (- i 3) );setq lst );while (strcat (if (minusp n) "-" "") (substr str 1 i) (vl-list->string (if (zerop i) (member (nth (length dl) lst) lst) lst)) b);strcat );DelimTxt
<Grins>
-Gary