Author Topic: 'write-line' to existing file ...  (Read 2020 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
'write-line' to existing file ...
« on: March 12, 2010, 01:35:08 PM »
Good morning everyone,
I've been searching for Writing to existing file or Append to existing file, but I can't find any post regarding such.
So I have a question for you all.
I want to write the dwgname & dwgprefix to a file, so I have this:
Code: [Select]
(setq Note (open NotePath "W"))
              (write-line dwgPref Note)
              (write-line dwgDesc Note)
              (setq Note (close Note))
Note:  NotePath is the path and name of the text document to be written to (already preset in the code earlier).

So this will write to the document, but if it is run again, it overwrites what was previously there.
I need to append to the document so the first  n  postings to the document will not be overwritten.

Can someone show me the way of enlightenment ??    :wink:

Thanks.

Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: 'write-line' to existing file ...
« Reply #1 on: March 12, 2010, 01:38:35 PM »
(setq handle (open "file.ext" "a"))

Short answer from blackberry.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Hangman

  • Swamp Rat
  • Posts: 566
Re: 'write-line' to existing file ...
« Reply #2 on: March 12, 2010, 03:08:31 PM »
...
Short answer from blackberry.

So when your out riding the trolly, do you have nothing better to do than surf this website ??  :D
Thank you.  I knew it was simple, but I couldn't find the answer.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pmwhite

  • Guest
Re: 'write-line' to existing file ...
« Reply #3 on: March 12, 2010, 04:24:17 PM »
Good morning everyone,
I've been searching for Writing to existing file or Append to existing file, but I can't find any post regarding such.
So I have a question for you all.
I want to write the dwgname & dwgprefix to a file, so I have this:
Code: [Select]
(setq Note (open NotePath "W"))
              (write-line dwgPref Note)
              (write-line dwgDesc Note)
              (setq Note (close Note))
Note:  NotePath is the path and name of the text document to be written to (already preset in the code earlier).

So this will write to the document, but if it is run again, it overwrites what was previously there.
I need to append to the document so the first  n  postings to the document will not be overwritten.

Can someone show me the way of enlightenment ??    :wink:

Thanks.


A good guide for this can be found in the help file.
launch vlisp. press f1 for help. Under the "Autolisp reference" subsection, select o -> open. Hope this also helps

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: 'write-line' to existing file ...
« Reply #4 on: March 13, 2010, 09:14:49 AM »
So when your out riding the trolly, do you have nothing better to do than surf this website ?? :D

not really
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst