newLISP Fan Club

Forum => newLISP in the real world => Topic started by: Fritz on March 23, 2010, 06:57:12 AM

Title: Inversion of eval-string function
Post by: Fritz on March 23, 2010, 06:57:12 AM
I have a variable, which contains some text with special symbols:


> {some symbols /""}
"some symbols \/"""


I want to save contents of this variable to the text file, with all that backslashes before quotes et cetera. Now I use function


(define (gnirts-lave x)
  (1 -1 (string (list x))))


But, may be, there exists more direct way to get "texted" value of a variable?
Title: Re: Inversion of eval-string function
Post by: HPW on March 23, 2010, 08:06:34 AM
How about:

> (setq a "some symbols /"")
"some symbols /""
> (source 'a)
"(set 'a "some symbols /\"")rnrn"
Title: Re: Inversion of eval-string function
Post by: Fritz on March 23, 2010, 08:19:28 AM
Quote from: "HPW"How about... source


Thanx, "source" looks promising for me. Only problem: source + sym dislike lists for some reason:


> (set 'test '(("a" '(1 2 3 4 5)) ("b" 52) ("c" "something")))
(("a" '(1 2 3 4 5)) ("b" 52) ("c" "something"))
> (source (sym (test 1 1)))
"(set  (sym "52" MAIN:MAIN)  nil)nn"
> (source (sym (test 0 1)))

ERR: number or string expected in function sym : (test 0 1)