- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I didn't realize until today that (getstring) will replace single backslashes ("\") with doubles ("\\").
So here I am with my c:ADDSUFF routine trying to add block numbers below existing lot numbers as new-lines in a bundle of mtexts.
(setq suffix (getstring T "\nEnter suffix: "))
So I type in (without quotes) "\nBlock 130"
and I get back "\\nBlock 130"
which when strcating creates "Lot 26\nBlock 130" as one line.
The solution is...
(setq suffix (vl-string-subst "\n" "\\n" suffix))
before the strcat.
Now the vl-string-subst function works on only the first occurrence it finds, so if you have multiple "\n" new-lines to add you might want to use this oldie from when I was still just older-middle-aged...
;;------------------------------------------------
;; Function added 12-01-00 (not used anywhere yet)
(defun @strsubst_all (new old what / l n)
(setq l (strlen new) n 0)
(while (setq n (vl-string-search old what n))
(setq what (vl-string-subst new old what n)
n (+ n l)
)
)
what
)
John F. Uhden
Solved! Go to Solution.