mostafa badran Posted April 14, 2014 Posted April 14, 2014 Hi all , I am having a problem when I try to create txt file like attachment can anyone help. thanks. (defun c:test(/ ) (vl-load-com) (initget 1 "txt csv") (setq filtyp (getkword "\nExport Type? (txt or csv)")) (setq top-str "" fname (getfiled "Specify File Name" "C:\\polyline size" filtyp 1)) (setq getarea (command "AREA" "o" pause )) (setq area (getvar "area")) (setq string (rtos area)) (setq sttxt(strcat "Area=" string)) (open fname "w") [color=red] (write-line sttxt fname) [/color] (close fname) ) Quote
cwake Posted April 14, 2014 Posted April 14, 2014 From memory, (on the phone), the file argument for both write-line and close is not the string of the file name and path, but rather the return from the open function. You need to capture the (open fname "w") into a variable and use that instead of fname. Quote
MSasu Posted April 14, 2014 Posted April 14, 2014 To put in code Clint's observation: [color=red](setq fileStream [/color](open fname "w")[color=red])[/color] (write-line sttxt [color=#ff0000]fileStream[/color]) (close [color=#ff0000]fileStream[/color]) Quote
mostafa badran Posted April 14, 2014 Author Posted April 14, 2014 From memory, (on the phone), the file argument for both write-line and close is not the string of the file name and path, but rather the return from the open function. You need to capture the (open fname "w") into a variable and use that instead of fname. To put in code Clint's observation: [color=red](setq fileStream [/color](open fname "w")[color=red])[/color] (write-line sttxt [color=#ff0000]fileStream[/color]) (close [color=#ff0000]fileStream[/color]) Thanks guys it work perfectly now. Thanks a lot. Quote
cwake Posted April 14, 2014 Posted April 14, 2014 Thanks for the code Mircea. :-) I was struggling with the phone. Quote
mostafa badran Posted April 14, 2014 Author Posted April 14, 2014 From memory, (on the phone), the file argument for both write-line and close is not the string of the file name and path, but rather the return from the open function. You need to capture the (open fname "w") into a variable and use that instead of fname. To put in code Clint's observation: [color=red](setq fileStream [/color](open fname "w")[color=red])[/color] (write-line sttxt [color=#ff0000]fileStream[/color]) (close [color=#ff0000]fileStream[/color]) Thanks for the code Mircea. :-) I was struggling with the phone. All roads lead to the Room.. Quote
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.