I have been using for many years this piece of code but now I have problems in batch process with Bricscad, I think is due to the recursion (AutoCAD has no problem).
The function is complicated so I would not be wrong, can anyone help me to rewrite without recursion?
;;*************************************************************
;; Copyright Vladimir Nesterovsky 1997, All Rights Reserved
;;
;; You may use, copy and distribute this program *unmodified*
;; for any non-commercial, non-profit purpose and without
;; charging any fee, if you keep this notice in its entirety
;; in all copies and in all your derived works.
;;
;; This program is provided "AS IS" and has absolutely
;; no warranty of any kind. Use it at your own risk.
;;
;; You're welcome to contact me about the possibility to use
;; this program commercially, and also with any comments and
;; requests at vnestr@netvision.net.il,
;; http://vnestr.tripod.com/
;;*************************************************************
;; a special encoding function for Xrecords to be used in dictionaries
(defun x-enlist ( lst ) ;; encode!
(cond
((null lst) lst)
((atom lst) ;; automatic code groups
(cond
((= 'REAL (type lst))
(list (cons 40 lst)))
((= 'INT (type lst))
(if ;; special handling of long integers
(< -32768 lst 32767)
(list (cons 70 lst))
(list (cons 41 (float lst)))))
((= 'STR (type lst))
(list (cons 1 lst)))
(T nil)))
((and (cdr lst) (atom (cdr lst)))
(list lst)) ;; pass dotted pair AS IS -- must be valid!!
((and (= (length lst) 3)
(apply 'and (mapcar 'numberp lst)))
(list (cons 10 lst)))
((cons '(2 . "{")
(reverse
(cons '(2 . "}")
(reverse
(apply 'append
(mapcar 'x-enlist lst) ))))
)
)
)
)