õ´ÜÀ§ ÄÞ¸¶Âï±â ¸®½À¿¡ ÀÖ´Â ¼ºê·çƾ..
;(setq txt "123456")
;(setq newtxt (cmo_1 txt)) ;ÀÌ·¸°Ô ÇØÁÖ¸é... newtext¿£.... ;"123,456" ÀÌ·¸°Ô õ´ÜÀ§¸¶´Ù ÄÞ¸¶°¡ ÂïÈ÷°Ô µË´Ï´Ù. ;ÄÞ¸¶Âï±â sub routine-----------------------------
(defun cmo_1(txt / a1 a2 kn txt2) (setq kn (strlen txt))
(setq txt2 (atof txt))
(if (and (>= txt2 1000)(< txt2 10000))(progn (setq a1 (substr txt1 1 1)) (setq a2 (substr txt1 2 (- kn 1))) (setq a3 (strcat a1 "," a2)) )) (if (and (>= txt2 10000)(< txt2 100000))(progn (setq a1 (substr txt1 1 2)) (setq a2 (substr txt1 3 (- kn 2))) (setq a3 (strcat a1 "," a2)) )) (if (and (>= txt2 100000)(< txt2 1000000))(progn (setq a1 (substr txt1 1 3)) (setq a2 (substr txt1 4 (- kn 3))) (setq a3 (strcat a1 "," a2)) )) a3
) ;;ÄÞ¸¶Âï±â sub routine-----------------------------
;; ¸í·É: (pds_comma "-254321.33") ;; "-254,321.33";; ¸í·É: (pds_comma "+3624.99999") ;; "+3,624.99999" (defun pds_comma (str / com_fr int_no com_no com_no2 i)
(setq com_fr (substr str 1 1)) (if (or (= com_fr "+") (= com_fr "-")) (setq str (substr str 2)) (setq com_fr nil) ) (setq int_no (strlen (rtos (atoi str) 2 0))) (setq com_no (fix (/ int_no 3)) com_no2 (rem int_no 3)) (cond ((= com_no2 0)(setq i 3 com_no (1- com_no))) ((= com_no2 1)(setq i 1)) ((= com_no2 2)(setq i 2)) ) (if (> com_no 0) (repeat com_no (setq str (strcat (substr str 1 i) "," (substr str (1+ i)))) (setq i (+ i 4)) ) ) (if com_fr (setq str (strcat com_fr str))) str ) ;;commaÁ¦°Å·çƾ----------------------------- (defun -comma (str / n) (while (setq n (vl-string-position (ascii ",") str)) (setq str (strcat (substr str 1 n) (substr str (+ n 2)))) ) str ) |