aaryan Posted June 28, 2012 Posted June 28, 2012 Hi All, Help me know writing new lines to existing file. eg. following line is existing in a file. (write-line "Hello-World" "filename") additional line to be written is (write-line "Good Morning" "filename") Thanks in advance Aaryan. Quote
Tharwat Posted June 28, 2012 Posted June 28, 2012 the file name should be variable and not a string . e.g . (setq filename "Complete path of file name HERE") (setq filename (open filename "w")) (write-line "Good Moring honey " filename) (close filename) Quote
MSasu Posted June 28, 2012 Posted June 28, 2012 You should look to Append mode of OPEN function for files access. Quote
MSasu Posted June 28, 2012 Posted June 28, 2012 Please try this code (don't remove the file): (setq ff (open "C:\\test.txt" "w")) (write-line "1st line" ff) (setq ff (close ff)) Then this one: (setq ff (open "C:\\test.txt" "a")) (write-line "2nd line" ff) (setq ff (close ff)) Now, may test again the first excerpt to see the difference. Quote
aaryan Posted June 28, 2012 Author Posted June 28, 2012 This is what i was missing APPEND mode. Thank You So Much Mircea. Regards Aaryan Quote
pBe Posted June 28, 2012 Posted June 28, 2012 You should look to Append mode of OPEN function for files access. Very subtle MSasu. 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.