marc578 Posted August 5, 2010 Share Posted August 5, 2010 Hi, I am having a problem when I try to create a *.txt file and write a simple line on it. I have the following code for my Autolisp function: (defun c:prueba4() (setq f(open "AAA.txt" "w")) (write-line "Hi friend" f) (close f) ) I made a *.txt file previously and I have not had problems creating it (it was a similar file). I probed on my office pc and it worked good, but when I returned to my house and tried to write the code above as a new file, I could not make it. So I decided to modify and change some of the text in the file that had already working correctly, but the new modified code does not set up, I always have as result the same original text. Can anyone had the same inconvenient? Regards Quote Link to comment Share on other sites More sharing options...
David Bethel Posted August 5, 2010 Share Posted August 5, 2010 I'd start by adding a debugging type call to see if the file has been opened: (defun c:prueba4() (setq f(open "AAA.txt" "w")) (prin1 (type f)) (write-line "Hi friend" f) (close f) ) It should display FILE at the command line possibly a file with that name is locked open, or a symbol has been overwritten -David Quote Link to comment Share on other sites More sharing options...
ReMark Posted August 5, 2010 Share Posted August 5, 2010 Are you using an ASCII text editor, such as Notepad, to write your lisp routine? When you finishing typing the routine out do you save the file before closing it? Did you load the original lisp routine into AutoCAD and test it? Did it work? Quote Link to comment Share on other sites More sharing options...
marc578 Posted August 5, 2010 Author Share Posted August 5, 2010 Hi, thank you for the prompt response. The program works, but the only thing is that AutoCAD create the file into the Template folder (C:\Documents and Settings\Marco\Configuración local\Datos de programa\Autodesk\AutoCAD 2007\R17.0\enu\Template), and I do not know why, because before it created the file into the My Documents folder. Can anybody know why AutoCAD do that (I do not change anythink in its options)? How can tell to AutoCAD to create all the files into the My Documents folder? Quote Link to comment Share on other sites More sharing options...
lpseifert Posted August 5, 2010 Share Posted August 5, 2010 try something similar to this (setq f(open "C:\\Documents and Settings\\Marco\\My Documents\\AAA.txt" "w")) Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted August 5, 2010 Share Posted August 5, 2010 This will definitely help me out. Thanks guys Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 6, 2010 Share Posted August 6, 2010 Just a hint see the double \\ in the file name as soon as you use directories with spaces in their name you can have problems Autocad will stop reading in some circumstances file names once it hits a space so always use \\. I mention it because lots of other examples here may only use a single backslash and you will wonder why it won't work when you try it. Scripts in particular use a space as return button press. VBA works ok just some times in lisp not working. Quote Link to comment Share on other sites More sharing options...
marc578 Posted August 6, 2010 Author Share Posted August 6, 2010 Thank you for your help, it finally works great. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.