Gentile Romano Posted June 1, 2021 Posted June 1, 2021 Anybody help me with a lisp will do so . . . Notepad text should be change as shown . . . Text ("Text" "0") Text1 ("Text1" "0") Text2 ("Text2" "0") Text3 ("Text3" "0") Quote
OMEGA-ThundeR Posted June 1, 2021 Posted June 1, 2021 I have no clue as of what you want or need... Quote
Gentile Romano Posted June 1, 2021 Author Posted June 1, 2021 Text1 change to ("Text1" "0") Text2 change to ("Text2" "0") Text3 change to ("Text3" "0") at Notepad Quote
mhupp Posted June 1, 2021 Posted June 1, 2021 (edited) Top is what your getting bottom is what you want? (setq F1 (open "path to txt") "w")) ;Create text file that you write to (princ (strcat "Existing LT Pole " (sslength SS) "\n" F1) ;if your counting with selection set (princ (strcat "Existing LT Pole " (itoa i) "\n" F1) ;if your counting with a variable ... (close F1) Edited June 1, 2021 by mhupp Quote
hmsilva Posted June 1, 2021 Posted June 1, 2021 Something like this? (defun c:demo (/ file file1 fname fname1 l) (if (and (setq fname (getfiled "Select the Text file" (getvar 'dwgprefix) "txt" 0)) (setq file (open fname "r")) (setq fname1 (getfiled "New Text File" (strcat (substr fname 1 (- (strlen fname) 4)) "-NEW") "txt" 1)) (setq file1 (open fname1 "w")) ) (progn (while (setq l (read-line file)) (write-line (strcat "(\"" l "\" \"0\")") file1) ) (close file) (close file1) ) ) (princ) ) I hope this helps. Henrique 1 Quote
BIGAL Posted June 2, 2021 Posted June 2, 2021 (edited) In Word can use ^p to replace end of line so can do 2 replaces one for (" and second " "0")^p but must save as text file and Word can do funny stuff leaving hidden characters. When i do this copy and paste to notepad to make sure. I use notepad++ and it appears to support \n as end of line but could not get sequence quite right will keep trying, I will try their forum etc. If you want it as lisp code to make a list need '("tetxt1" "0") Edited June 2, 2021 by BIGAL 1 Quote
BIGAL Posted June 2, 2021 Posted June 2, 2021 (edited) Found it easy to do in Notepad++ you can prefix and suffix all lines, I am no expert but with a bit of practice would become super quick. Yes tried it out. PS its free. Ok found on Notepad++ forum. prefix go to left 1st character top line press Alt+Lmouse drag down this does a vertical column, just type what you want (" suffix got to top line, last character again Alt+Lmouse drag down creates a vertical column, just type " "0") All done. Edited June 2, 2021 by BIGAL Quote
Gentile Romano Posted June 2, 2021 Author Posted June 2, 2021 (edited) That's amazing silva ! That worked beautifully. Thank you. I appreciate the help very much ! Thanks to BIGAL as well . . . & I need little more from silva as below Image. Merge 2 notepads & create new Edited June 2, 2021 by Gentile Romano Quote
hmsilva Posted June 2, 2021 Posted June 2, 2021 5 hours ago, Gentile Romano said: That's amazing silva ! That worked beautifully. Thank you. I appreciate the help very much ! Thanks to BIGAL as well . . . & I need little more from silva as below Image. Merge 2 notepads & create new You're welcome, @Gentile Romano A quick one, minimally tested... (defun c:demo (/ file file1 file_n fname fname1 fname_n i l lst lst1 n) (if (and (setq fname (getfiled "Select the first Text file" (getvar 'dwgprefix) "txt" 0)) (setq file (open fname "r")) (setq fname1 (getfiled "Select the second Text file" (getvar 'dwgprefix) "txt" 0)) (setq file1 (open fname1 "r")) (setq fname_n (getfiled "New Text File" (strcat (substr fname 1 (- (strlen fname) 4)) "-NEW") "txt" 1)) (setq file_n (open fname_n "w")) ) (progn (while (setq l (read-line file)) (setq lst (cons (strcat "(\"" l "\" ") lst)) ) (close file) (setq lst (reverse lst)) (while (setq l (read-line file1)) (setq lst1 (cons (strcat "\"" l "\")") lst1)) ) (close file1) (setq lst1 (reverse lst1)) (setq n 0) (if (= (setq i (length lst)) (length lst1)) (progn (while (< n i) (write-line (strcat (nth n lst) (nth n lst1)) file_n) (setq n (1+ n)) ) (close file_n) ) (prompt "\nFiles do not have the same number of lines... ") ) ) ) (princ) ) Hope this helps, Henrique Quote
hmsilva Posted June 2, 2021 Posted June 2, 2021 Just now, Gentile Romano said: awesome ! thanks silva You're welcome, @Gentile Romano Glad I could help Henrique Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.