append read-line error

Discussion in 'AutoCAD' started by nalsur8, Feb 24, 2004.

  1. nalsur8

    nalsur8 Guest

    (setq FileName "login.txt")
    (setq FindF(findfile FileName))
    (setq OpenFile(open FindF "r"))
    (while
    (setq ReadLine(read-line OpenFile))
    (setq AppList(append AppList(list ReadLine)))
    (close OpenFile)
    );while

    1st line to read-file OK
    2nd line to read-file error
    i want each line of file append to list and
    set_tile to list_box
     
    nalsur8, Feb 24, 2004
    #1
  2. nalsur8

    BillZ Guest

    It would appear that you are closing the file before you're done reading it.

    (setq FileName "login.txt")
    (setq FindF(findfile FileName))
    (setq OpenFile(open FindF "r"))
    (while
    (setq ReadLine(read-line OpenFile))
    (setq AppList(append AppList(list ReadLine)))
    );while

    (close OpenFile)

    Try this way.

    Bill
     
    BillZ, Feb 24, 2004
    #2
  3. nalsur8

    hawstom Guest

    Note that it is much more efficient to use (cons) and (reverse) than to use (append). Like this:

    (setq FileName "login.txt")
    (setq FindF(findfile FileName))
    (setq OpenFile(open FindF "r"))
    (while
    (setq ReadLine(read-line OpenFile))
    (setq AppList(cons ReadLine AppList))
    );while
    (close OpenFile)
    (setq AppList (reverse Applist))
     
    hawstom, Feb 24, 2004
    #3
  4. nalsur8

    nalsur8 Guest

    i make 1 dialog box to display all text contens from 1 file *.txt and i just
    create 1 button for clear the text in that file to become emty file,
    i no ideal how to make the code can yours tell me how to do
     
    nalsur8, Feb 25, 2004
    #4
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.