;; | --------------------------------------------------------------------------- ;; | MI_ListHx ;; | --------------------------------------------------------------------------- ;; | Function : MI_ListHx accepts a list in the form: ;; | (1's 16s 16x16s 16x16x16s ...) ;; | and returns it as a hexadecimal string. The list may be either ;; | stored in a variable (listhx var), or quoted (listhx '(integer ;; | integer ...)). ;; | Argument : 'lst - Hexadecimal List form ;; | Return : The hexadecimal string ;; | Update : August 6, 1998 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | --------------------------------------------------------------------------- (defun MI_ListHx (lst / carry remain rest num str) ;reverse list & correct if needed (setq carry 0 rest lst lst nil) ;initialize (while (setq num (car rest)) ;get 1st member (setq rest (cdr rest) ;remainder of list num (+ num carry) ;accumulate 1's remain (rem num 16) ;remainder carry (/ num 16) ;pull out multiples of 16 lst (append (list remain) lst) ;rebuild list ) ) ;convert to hex (setq str "") (while (setq num (car lst)) ;process each int at a time (setq str (strcat ;build a string str (if (> num 9) (chr (+ 55 num)) ;convert 0-9 (chr (+ 48 num)) ;convert A-F ) ) lst (cdr lst) ;reset lst to remainder of lst ) ) str ;return string result )