welcome rjb709739...
What you are trying to do is create a base 23 (26 - 3 letters) number.
It got me thinking that it would be useful to create other base numbers using any characters you might choose.
I came up with this.
Let me know if you find any bugs...
P=
Code:
;___________________________________________________________________________________________________________|
;
;
; Function to convert integers to and from a BaseK String
;___________________________________________________________________________________________________________|
(defun C:BaseK ()
(and
(setq strBase "ABCDEFGHJKLMNPRSTUVWXYZ") ;AlphaNumeric
; (setq strBase "0123456789ABCDEF") ;Hexadecimal
; (setq strBase "0123456789") ;Decimal
; (setq strBase "01") ;Binary
(setq intNumber (getint "\nEnter Integer: "))
(setq strValue (Base10ToBaseK strBase intNumber));<-Convert Integer to BaseK string
(princ (strcat "\nValue in " strBase " Values: "))
(princ strValue)
(setq intNumber (BaseKToBase10 strBase strValue));<- Convert BaseK String to Integer
(princ "\n")
(princ intNumber)
)
(princ)
)
;___________________________________________________________________________________________________________|
(defun Base10ToBaseK (strBase intNumber / intBase intDigit intRemainder lstReturn )
(setq intBase (strlen strBase))
(if (= intNumber 0)(setq lstReturn (list 0)))
(while (> intNumber 0)
(setq intDigit (/ intNumber intBase))
(setq intRemainder (- intNumber (* intBase intDigit)))
(setq lstReturn (cons intRemainder lstReturn))
(setq intNumber intDigit)
)
(apply 'strcat (mapcar '(lambda (X)(substr strBase (1+ X) 1)) lstReturn))
)
;___________________________________________________________________________________________________________|
(defun BaseKToBase10 (strBase strValue / intBase intCount intTotal)
(setq intBase (strlen strBase))
(setq intTotal 0)
(repeat (setq intCount (strlen strValue))
(setq intTotal (+ intTotal
(* (expt intBase (- (strlen strValue) intCount))
(vl-string-search (substr strValue intCount 1) strBase)
)
)
)
(setq intCount (1- intCount))
)
intTotal
)
(vl-load-com)