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

0 Members and 1 Guest are viewing this topic.

Dilan

  • Newt
  • Posts: 23
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_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2122
  • 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
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2122
  • 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
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Dilan

  • Newt
  • Posts: 23
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: 812
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)
  )
)
vevo.bg

roy_043

  • Water Moccasin
  • Posts: 1895
  • 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_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2122
  • 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
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.