TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Cawaugh on January 02, 2007, 11:06:45 AM
-
(write-line (strcat "(find_replace " includetxt " " mdwg " " mstringlist " " SearchAtt " " case " " firstonly ")") Ofil)
The above gives me an error which I believe is due to trying to strcat text with lists. mstringlist and SearchAtt are lists. How can I get these lists into a script file with write-line? What I am trying to do is pass a list as an argument to the find_replace function. When the script is run it has this as a line to be read:
(find_replace "1" "y" list-of-strings-to-look-for list-of-atts-to-search-through "1" "1")
Thanks in advance for any help. :-)
-
Chuck,
When you want to string characters (strcat) and an item is a list, use 'vl-princ-to-string' for that item. So something like
(strcat
"Happy"
(vl-princ-to-string '(1 2 3 45))
(setq Test " This is a test. ")
)
Returns
"Happy(1 2 3 45) This is a test. "
Hope that helps.
-
Breaking this down:
(write-line (strcat "(find_replace " includetxt " " mdwg " " mstringlist "
" SearchAtt " " case " " firstonly ")") Ofil)
It would appear that find_replace takes several string arguments
(find_replace " includetxt " " mdwg " " mstringlist " " SearchAtt " " case " " firstonly ")
And returns a string that is then written to a file.
If that is the case then no strcat is needed.
(write-line (find_replace " includetxt " " mdwg " " mstringlist " " SearchAtt " " case " " firstonly ") Ofil)
If that is not the case then more information on the find_replace function is needed.
-
Chuck,
When you want to string characters (strcat) and an item is a list, use 'vl-princ-to-string' for that item. So something like
(strcat
"Happy"
(vl-princ-to-string '(1 2 3 45))
(setq Test " This is a test. ")
)
Returns
"Happy(1 2 3 45) This is a test. "
Hope that helps.
What I am finding out is that I cannot get a list written out so that when the script is run the below setq will not work. I'm trying to set the variable mstringlist to a list but the strcat won't let me.
(write-line (strcat "(setq " "mstringlist " mstringlist ")") Ofil)
-
Maybe this
(write-line
(strcat
"(find_replace "
includetxt
" "
mdwg
" "
(vl-princ-to-string mstringlist)
" "
(vl-princ-to-string SearchAtt)
" "
case
" "
firstonly
")"
)
Ofil
)
-
Boy, I sure missed that one. :-o
-
Boy, I sure missed that one. :-o
Thats okay, you can have the next one then Alan. :-D