; 숫자 순차 변환 LSP
; HEX.LSP
; 저자 : 황 진호
; e-mail : hjinho@bcline.com
; 날짜 : 2001년 8월 21일
; 공유화일 : hex.dcl
; 저자권은 황 진호에게 있으며 유상 배포를 금함
; 무상 배포는 언제든 환영합니다.
(defun 10ant->Nantilog (numint nant / numstr)
(setq n 1 numstr nil)
(while (<= nant (progn (setq numstr (cons (rem numint nant) numstr))
(setq numint (/ (+ numint (- (rem numint nant))) nant))
)
)
nil
)
(if (< 0 numint) (setq numstr (cons numint numstr)))
(apply ‘strcat (mapcar ‘(lambda (x) (nth x ‘(“0” “1” “2” “3” “4” “5” “6” “7” “8” “9” “A” “B” “C” “D” “E” “F”))) NUMSTR))
)
(defun Nantilog->10ant (numstr nant / num)
(setq n 1 num (list))
(repeat (strlen numstr)
(setq num (append num (list (* (expt nant (1- n))
(1- (length (member (strcase (substr numstr (+ (1+ (strlen numstr)) (- n)) 1))
‘(“F” “E” “D” “C” “B” “A” “9” “8” “7” “6” “5” “4” “3” “2” “1” “0”)
)
)
)
)
)
)
)
(setq n (1+ n))
)
(apply ‘+ num)
)
(defun ent*sel (msg / es)
(setvar “errno” 0)
(while (and (not es) (/= (getvar “errno”)52))
(if (= (type msg) ‘STR)(setq es (entsel msg)) (setq es (entsel)))
)
es
)
(defun do_txt()
(setq txt1 (get_tile “tname1”) txt2 (get_tile “tname2”))
(if (= “1” (get_tile “button1”)) (setq n1 3))
(if (= “1” (get_tile “button2”)) (setq n1 2))
(if (= “1” (get_tile “button3”)) (setq n1 1))
(if (= “1” (get_tile “button4”)) (setq n2 5))
(if (= “1” (get_tile “button5”)) (setq n2 4))
(if (= “1” (get_tile “button6”)) (setq n2 3))
(if (= “1” (get_tile “button7”)) (setq n2 2))
(if (= “1” (get_tile “button8”)) (setq n2 1))
)
(Defun c:hex()
(setq numb (load_dialog “hex”))
(new_dialog “hexbox” numb)
(set_tile “button3” “1”)
(set_tile “button8” “1”)
(mode_tile “tname1” 3)
(mode_tile “tname2” 3)
(action_tile “accept” “(do_txt) (done_dialog)”)
(action_tile “cancel” “(do_txt) (done_dialog)”)
(start_dialog)
(unload_dialog numb)
(setq t_nil 1 cnt 1 )
(cond ((= txt1 “”) (setq t_nil 0))
((/= txt1 “”) (repeat (strlen txt1)
(setq chktxt (substr txt1 cnt 1))
(cond ((/= n1 3) (if (not (member chktxt ‘(“1” “2” “3” “4” “5” “6” “7” “8” “9” “0”))) (setq t_nil 0)))
((= n1 3) (if (not (member chktxt ‘(“1” “2” “3” “4” “5” “6” “7” “8” “9” “0” “A” “B” “C” “D” “E” “F” “a” “b” “c” “d” “e” “f”))) (setq t_nil 0)))
)
(setq cnt (1+ cnt))
)
)
)
(cond ((= t_nil 1) (while (setq oldtxt (ent*sel “n교체를 원하는 문자를 선택하세요..(^o^)a :”))
(setq oldtxt (entget (car oldtxt)))
(cond ((/= n1 1) (setq txtvol (strlen txt1))
(setq vol (- n2 txtvol))
(if (>= vol 0) (setq headnum (substr “0000” 1 vol)))
(setq jointxt (strcat txt2 headnum (strcase txt1)))
)
((= n1 1 ) (setq jointxt (strcat txt2 txt1)))
)
(setq old (assoc 1 oldtxt) new (cons 1 jointxt))
(setq oldtxt (subst new old oldtxt))
(entmod oldtxt)
(setq txt1 (cond ((/= n1 3) (itoa (1+ (atoi txt1))))
((= n1 3) (10ant->Nantilog (1+ (Nantilog->10ant txt1 16)) 16))
)
)
)
)
((= t_nil 0) nil)
)
)
2007쓰는데 잘못된 인수유형 stringp nil<--욜케 나오는데 왜 그런거에요?;;