dcpanchal_2005 Posted June 2, 2009 Posted June 2, 2009 hi, i Want to write ".txt" or ".csv" file from autocad. the problem is which flag i use for write the file . i.e. my file maybe new or Existing. if file is already exist then data must be append otherwise create a new file... i user following syntax (setq tempfile (getfiled "Save File As" "c:\" "txt;csv;*" 1)) Quote
Freerefill Posted June 2, 2009 Posted June 2, 2009 Not sure if this will help, I haven't used getfiled very much, but I did notice one thing; you have a single backslash, which would mess up your code. Take a look in the help file for AutoLISP control codes. The short version is: ever use "\n" to create a new line? It's similar to that. In terms of directories, since most have a backslash in them, you have two options; use a forwardslash in place of the backslash, or, use the backslash as a control code to input a backslash, id est, "\\". Hope this helps. ^.^ Quote
dcpanchal_2005 Posted June 2, 2009 Author Posted June 2, 2009 thanks for reply "freerefill" you r right. it is mistake of typing. i already use "\\". Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 I would use bit code 9 (8+1) for existing/or create new. Quote
Commandobill Posted June 2, 2009 Posted June 2, 2009 If it's just a .TXT or a .CSV and you are saving it to your C drive couldnt you just... (setq flname (strcat "C:\\" (getstring "Enter The name of your file (Specify .TXT or .CSV): "))) (setq file (open flname "a")) (write-line "Whatever you want" file) (close file) in this case it will create new if it doesn't exist or append if it does... just a thought Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 If it's just a .TXT or a .CSV and you are saving it to your C drive couldnt you just... (setq flname (strcat "C:\\" (getstring "Enter The name of your file (Specify .TXT or .CSV): "))) (setq file (open flname "a")) (write-line "Whatever you want" file) (close file) in this case it will create new if it doesn't exist or append if it does... just a thought yes, but you would have to specify the folders/sub-folders and full path name. Getfiled allows you to browse various folders and will return the resultant filename. 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.