+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Senior Member
    Using
    Map 3D 2007
    Join Date
    May 2011
    Location
    autocad
    Posts
    134

    Default write-line new lines to existing file

    Registered forum members do not see this ad.

    Hi All,

    Help me know writing new lines to existing file.
    eg. following line is existing in a file.
    Code:
    (write-line "Hello-World" "filename")
    additional line to be written is
    Code:
    (write-line "Good Morning" "filename")
    Thanks in advance
    Aaryan.

  2. #2
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,664

    Default

    the file name should be variable and not a string .

    e.g .

    Code:
    (setq filename "Complete path of file name HERE")
    
    (setq filename (open filename "w"))
    (write-line "Good Moring honey " filename)
    (close filename)
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  3. #3
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,041

    Default

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

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  4. #4
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,041

    Default

    Please try this code (don't remove the file):
    Code:
    (setq ff (open "C:\\test.txt" "w"))
     (write-line "1st line" ff)
    (setq ff (close ff))
    Then this one:
    Code:
    (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.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  5. #5
    Senior Member
    Using
    Map 3D 2007
    Join Date
    May 2011
    Location
    autocad
    Posts
    134

    Default

    This is what i was missing APPEND mode.
    Thank You So Much Mircea.

    Regards
    Aaryan

  6. #6
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,152

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by MSasu View Post
    You should look to Append mode of OPEN function for files access.
    Very subtle MSasu.

Similar Threads

  1. how to write a program to get the lines like in the attachment
    By aswini in forum AutoLISP, Visual LISP & DCL
    Replies: 22
    Last Post: 26th May 2012, 08:09 am
  2. How can I use tracking to start a line from an existing line
    By g-dub in forum AutoCAD Beginners' Area
    Replies: 12
    Last Post: 29th Jul 2010, 03:31 am
  3. Write-line lisp???
    By looseLISPSsinkSHIPS in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 12th Mar 2010, 10:01 am
  4. Draw line in the mid distance of 2 existing lines
    By motee-z in forum AutoLISP, Visual LISP & DCL
    Replies: 28
    Last Post: 5th Jan 2007, 05:17 pm
  5. Drawing a parallel line to unknown angled existing line
    By berol in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 29th Aug 2006, 12:06 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts