home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / autocad / may91.arj / TIP657.LSP < prev    next >
Text File  |  1991-05-13  |  920b  |  39 lines

  1. ;TIP657.LSP   List to String   (c)1991, George Zinsmeister
  2.  
  3. (defun LTOA (LIST MODE PREC / I ITEM S)
  4.   (if (= MODE nil)(setq MODE (getvar
  5.     "LUNITS")))
  6.   (if (= PREC nil)(setq PREC (getvar
  7.     "LUPREC")))
  8.   (if (= (type (cdr LIST)) 'LIST)
  9.     (progn
  10.       (setq S "" I 0 ITEM (nth 0 LIST))
  11.       (while ITEM
  12.         (setq
  13.           S (strcat S (CONVERT ITEM MODE
  14.              PREC) " ")
  15.           I (1+ I)
  16.           ITEM (nth I LIST)
  17.         )
  18.       )
  19.       (strcat "(" (substr S 1 (1-
  20.         (strlen S))) ")")
  21.     )
  22.     (strcat "(" (CONVERT (car LIST) MODE
  23.       PREC) " . " (CONVERT (cdr LIST)
  24.       MODE PREC) ")")
  25.   )
  26. )
  27. (defun CONVERT (ITEM MODE PREC)
  28.   (cond
  29.     ((= (type ITEM) 'INT) (itoa ITEM))
  30.     ((= (type ITEM) 'REAL)
  31.       (rtos ITEM MODE PREC))
  32.     ((= (type ITEM) 'STR)
  33.       (strcat "\"" ITEM "\""))
  34.     ((= (type ITEM) 'LIST)
  35.       (LTOA ITEM MODE PREC))
  36.   )
  37. )
  38. 
  39.