Author Topic: help text to list  (Read 1802 times)

0 Members and 1 Guest are viewing this topic.

TopoWAR

  • Newt
  • Posts: 135
help text to list
« on: February 20, 2013, 03:11:14 PM »
hello, a help please, I have the following string:
Code: [Select]
(read "(b (91.1849 87.7505 0.0))")but I need to return the value b = b and b = B not,

return value like this:
Code: [Select]
'(b (91.1849 87.7505 0.0))
took 2 hours trying everything and I returned the b and B,  :oops: help me thank you
« Last Edit: February 20, 2013, 03:31:31 PM by TopoWAR »
Thanks for help

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: help text to list
« Reply #1 on: February 20, 2013, 03:57:48 PM »
The B is a variable NAME and B is the same as b in the eyes of LISP.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

TopoWAR

  • Newt
  • Posts: 135
Re: help text to list
« Reply #2 on: February 20, 2013, 04:04:29 PM »
CAB ,
see, I do the following, I convert a list to a text string, as shown in b is a text
Code: [Select]
(setq est (vl-princ-to-string (list "b" '(100. 100. 0.0))))
the problem that when I use
Code: [Select]
(read est)I returned b uppercase:
Code: [Select]
'(B (100.0 100.0 0.0))I need to return the same value as before: lower case b

I need is retrieve back the string "b"

I hope I explained, thanks
« Last Edit: February 20, 2013, 04:18:56 PM by TopoWAR »
Thanks for help

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: help text to list
« Reply #3 on: February 20, 2013, 04:15:26 PM »
I see what you are doing.

You need to separate the individual items and recreate the list. Read will convert to uppercase, so you need to do something like this:

Code: [Select]
(setq est (vl-princ-to-string (list "b" '(100. 100. 0.0))))
(setq val (substr est 2 1))

As you see, the "b" in the string is extracted to a new variable

Without understanding the larger use, it is difficult to provide guidance.

What are you trying to do?

Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TopoWAR

  • Newt
  • Posts: 135
Re: help text to list
« Reply #4 on: February 20, 2013, 04:23:15 PM »
Keith™

it is a solution.
so I would stay to the end.
thanks :laugh:

Code: [Select]
(setq est (vl-princ-to-string (list "abc" '(100. 100. 0.0))))
(setq val (substr est 2 (1- (vl-string-search " " est))))
Thanks for help

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: help text to list
« Reply #5 on: February 20, 2013, 05:07:15 PM »
Glad to be of assistance
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: help text to list
« Reply #6 on: February 20, 2013, 06:11:02 PM »
Alternatively, you could use vl-prin1-to-string to preserve the string data type:
Code: [Select]
_$ (read (vl-prin1-to-string '("b" (100.0 100.0 0.0))))
("b" (100.0 100.0 0.0))

TopoWAR

  • Newt
  • Posts: 135
Re: help text to list
« Reply #7 on: February 20, 2013, 06:32:02 PM »
Lee Mac , excellent :lol:

as simple as changing
Code: [Select]
vl-princ-to-stringby
Code: [Select]
vl-string-to-prin1
thanks for sharing.
« Last Edit: February 20, 2013, 06:39:30 PM by TopoWAR »
Thanks for help