TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Dilan on July 12, 2019, 08:44:02 PM

Title: Re: List of numbers to String
Post by: Dilan on July 12, 2019, 08:44:02 PM
Hello
I have a list :
Code: [Select]
(1 74678.6 53741.6 0.0)How do i convert it to value :
Code: [Select]
"1 74678.6 53741.6 0.0"
Tell me please....
Title: Re: List of numbers to String
Post by: kdub_nz on July 12, 2019, 10:04:42 PM
Ugly, but it should work for you with the different types of numbers

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (setq xx '(1 74678.6 53741.6 0.0))
  3. (setq result
  4.        (vl-string-subst  ""  ")"
  5.          (vl-string-subst "" "(" (vl-prin1-to-string xx))
  6.        )
  7. )
  8.  


(1 74678.6 53741.6 0.0)
"1 74678.6 53741.6 0.0"
Title: Re: List of numbers to String
Post by: kdub_nz on July 12, 2019, 10:08:39 PM
Dilan,
It's better not to post in old threads with topics that are slightly different.
Title: Re: List of numbers to String
Post by: Dilan on July 12, 2019, 11:55:49 PM
Dilan,
It's better not to post in old threads with topics that are slightly different.
thanks for the help, kdub.
I will remember your comment about posting messages in old topics.
Thanks again.
Title: Re: Re: List of numbers to String
Post by: Grrr1337 on July 13, 2019, 06:59:08 AM
Code - Auto/Visual Lisp: [Select]
  1. (setq itm '(1 74678.6 53741.6 0.0))
  2. (setq result
  3.   (eval
  4.     (append
  5.       '('((x a b c d) (strcat a x b x c x d)))
  6.       '(" ")
  7.       (mapcar 'vl-prin1-to-string itm)
  8.     )
  9.   )
  10. )
Title: Re: List of numbers to String
Post by: roy_043 on July 13, 2019, 10:41:24 AM
Code - Auto/Visual Lisp: [Select]
  1. (setq xx '(1 74678.6 53741.6 0.0))
Title: Re: List of numbers to String
Post by: kdub_nz on July 13, 2019, 05:35:52 PM
:)