This is what I use for leading 0's
(defun AT:NumFix (s n)
;; Fix number string with leading zeros
;; s - Number string to fix
;; n - Number of characters for final string
;; Alan J. Thompson, 10.29.09
;; (AT:NumFix i 3) i= 1 = 001
(if (< (strlen s) n)
(AT:NumFix (strcat "0" s) n)
s
)
)
(defun c:test (/ pre tmp)
(if (and (setq pre (getint "Enter Drawing Number: ")) (> pre 0) (< pre 999))
(setq tmp (AT:NumFix (itoa pre) 3))
(Alert "\nNumber must be in the range 001-999.")
)
tmp
)