Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Solved by martti.halminen. Go to Solution.
@ProfWolfMan wrote:
(they wants backslash and underscore followed by path)._$ (vl-string-subst "\_" "$temp" "$temppath")"_path"_$ (vl-string-subst "\\_" "$temp" "$temppath")"\\_path"How can i get result as "\_path"
_$ (setq p (vl-string-subst "\\_" "$temp" "$temppath"))
"\\_path"
That is actually the result you want:
_$ (vl-string->list p)
(92 95 112 97 116 104)
As you can see, the string only contains 6 characters. So use PRINC to print it out.
What is happening here is, that in Lisp the backslash is an escape character in strings, used to hide any special meaning
from the next character, for example when you want to have a quotation mark as a part of the string contents, instead of ending the string.
So, if you want to include a backslash in a string, it has to be escaped by another backslash in printed representation, but the string itself only contains one. PRINT and PRIN1 are intended to output a string in a form that produces the same string when read in by READ or LOAD, so they also show those escape characters. PRINC is intended for human-readable output, so it doesn't print the quotation marks and escape characters.
A sometimes usable alternative in file names is to use a slash as path separator instead of a backslash: AutoCAD and Windows also accept this in most usages, and it doesn't have the escape character behaviour.
--
thats right
the final result will be
"\_path"
try this on a text entity:
(entmod (subst (cons 1 (vl-string-subst "\\_" "$temp" "$temppath")) (assoc 1 (setq ss (entget (car (entsel))))) ss))
Even if you're going to use this string to write to an external file
(write-line (vl-string-subst "\\_" "$temp" "$temppath")Filename)
The result is still the same
\_path
Hope this will make you understand: