Jump to content

Recommended Posts

Posted

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.

Posted

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)

Posted

You should look to Append mode of OPEN function for files access.

Posted

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.

Posted

This is what i was missing APPEND mode.

Thank You So Much Mircea.

 

Regards

Aaryan

Posted
You should look to Append mode of OPEN function for files access.

 

Very subtle MSasu. :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...