Author Topic: Re: List of numbers to String  (Read 344 times)

0 Members and 1 Guest are viewing this topic.

Dilan

  • Mosquito
  • Posts: 14
Re: List of numbers to String
« 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....

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1367
  • class keyThumper<T>:ILazy<T>
Re: List of numbers to String
« Reply #1 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"
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1367
  • class keyThumper<T>:ILazy<T>
Re: List of numbers to String
« Reply #2 on: July 12, 2019, 10:08:39 PM »
Dilan,
It's better not to post in old threads with topics that are slightly different.
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

Dilan

  • Mosquito
  • Posts: 14
Re: List of numbers to String
« Reply #3 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.

Grrr1337

  • Swamp Rat
  • Posts: 695
Re: Re: List of numbers to String
« Reply #4 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. )
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)

roy_043

  • Water Moccasin
  • Posts: 1713
  • BricsCAD 18
Re: List of numbers to String
« Reply #5 on: July 13, 2019, 10:41:24 AM »
Code - Auto/Visual Lisp: [Select]
  1. (setq xx '(1 74678.6 53741.6 0.0))

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1367
  • class keyThumper<T>:ILazy<T>
Re: List of numbers to String
« Reply #6 on: July 13, 2019, 05:35:52 PM »
:)
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober