Using "replace" on a list of symbols

Started by dukester, December 22, 2014, 12:46:53 PM

Previous topic - Next topic

dukester

Is it possible?



I have 5 symbols containing various strings.



I want to replace all the "<" characters with "<"  in one, slick expression.



I was thinking of:


(dolist (s (var1 var2 var3 var4 var5))
(replace "<" s "<"))


but it's not working!



Would someone point me in the right direction - please!!
duke

rrq

#1
(dolist (s '(var1 var2 var3 var4 var5))
(replace "<" (eval s) "<"))

dukester

#2
Thx Ralph!!  I'm doing something wrong, because it's still not working for me. I did try your suggestion before posting.



Here the complete test function:
(define (addData)
(set 'formTitle "<abc")
(set 'formDesc "<def")
(set 'formWords "<xyz")
(set 'formEmail "ijkl")
(set 'formURL "<opq")
(set 'data_file "data.txt")
(dolist (s '(formTitle formDesc formWords formEmail formURL))
(replace ("<"  s "<"))
(append-file data_file (string formTitle "|" formDesc "|" formWords "|" formEmail "|" formURL "n")))
)
(addURL)


I keep getting:



 ERR: value expected in function replace : s

called from user defined function addURL



Where have I blown it?
duke

rrq

#3
(eval s)

dukester

#4
I haven't tried your (eval s) trick yet.



I solved the issue with:


(define (addData)
(set 'formTitle "<abc")
(set 'formDesc "<def")
(set 'formWords "<xyz")
(set 'formEmail "ijkl")
(set 'formURL "<opq")
(set 'data_file "data.txt")

(set 'data (string formTitle "|" formDesc "|" formWords "|" formEmail "|" formURL))

(replace ("<"  data "<")
(println  data)
)
(addData)


Thx for your input!!
duke