본문 바로가기
autocad

대소문자 바꾸기

by kmlab 2025. 9. 3.

 

 

아스키 코드

파일:attachment/1275273992_asciitable.gif 2열 이후의 코드들은 위키에서 사용할 수

namu.wiki

;; by ASCII
(chr (+ (ascii "C") 32)) ;; "C" -->"c"
(chr (- (ascii "c") 32)) ;; "c" --> "C"

;; by Lisp fuction
(strcase "CcCc") ;; "CCCC"
(strcase "CcCc" T) ;; "cccc"

;; 소문자는 대문자보다 ascii 10진법으로 32 크다.
;; strcase 함수로 일괄 대소문자 변경.

;; Changing the capitalize the first letter
(defun KM:CAPI ( _STR / str0 str1 str2 str3 Nstr)
(setq str0 _STR)
(setq str1 (strcase str0 T))
(setq str2 (substr str1 1 1))
(setq str3 (substr str1 2))
(setq str2 (chr (- (ascii str2) 32)))
(setq Nstr (strcat str2 str3))
)

;; substr 함수로 첫글자와 두번째부터 글자를 분리하고, 첫글자만 대문자로 변경

(defun c:capi ( / )
(setq txtdxf (entget (car (entsel)))) ;; select a txt
(setq str (cdr (assoc 1 txtdxf))) ;; extract string from the txt
(KM:CAPI str) 
(princ)
)

반응형