Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

append read-line error

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
182 Views, 3 Replies

append read-line error

(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 -- ---------------------------------------- Design/Engineering Dept.
3 REPLIES 3
Message 2 of 4
BillZ
in reply to: Anonymous

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
Message 3 of 4
hawstom
in reply to: Anonymous

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))
Message 4 of 4
Anonymous
in reply to: Anonymous

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 -- ---------------------------------------- Design/Engineering Dept. hawstom wrote in message news:4438173.1077654195387.JavaMail.jive@jiveforum1.autodesk.com... > 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))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost