(How2) save data to NEW (ascii) FILE

Discussion in 'AutoCAD' started by RoNin Warrior, Oct 20, 2004.

  1. Hi there,

    I'm looking for a way to write data to a file, using a 'save as' routine. I want to export a list of drawing names, to a file.

    Using ACAD2002 AutoLISP with DOSLIB 6.1.5, getting the filenames and writing them to a file isn't the problem.

    The problem is, I want the user to be able to save the file, to a new file, which he/she supplies/selects from a dialog.

    It's possible, using DOSLib's DOS_GETFILED, to select an existing file to overwrite, but creating a new file is a bit more tricky. (Right click - New - Text document / then rename the "new text document.txt" to "blabla.lst", click it (to select)
    and then click the "Open" button. (instead of "save"))

    This is however NOT really what I want.
    I want (at least) a 'save' and a 'create new file' button.

    Any help/suggestion is welcome!

    My current code:

    (setq filename (DOS_GETFILED "Select list:" (DOS_PWDIR) "ACAD Drawings list (*.lst)|*.lst|All files (*.*)|*.*||"))
    (if (/= filename nil)
    (progn
    (DOS_WAITCURSOR T)
    (setq file_w (open filename "w"))
    (setq l 0)
    (while (< l (length file_list))
    (setq filepath (nth l file_list))
    (write-line filepath file_w)
    (setq l (1+ l))
    ); end while
    (close file_w)
    (setq modified 0)
    (DOS_WAITCURSOR)
    ); end progn
    ); end if
     
    RoNin Warrior, Oct 20, 2004
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.