TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: vinnyg on November 19, 2003, 10:09:24 AM

Title: deleting files via lisp
Post by: vinnyg on November 19, 2003, 10:09:24 AM
Is it possible to delete a file from any directory using lisp?

If so, how can this be accomplished?

I'm new at lisp, so any info regarding a procedure like this would
be helpful!

Thanks :roll:
Title: deleting files via lisp
Post by: Craig on November 19, 2003, 10:16:59 AM
Yep, you sure can
(vl-file-delete filename)
There will be many more post coming soon and I would really love to start something for you but I am in the middle of a project of my own so just hang in there.
Title: deleting files via lisp
Post by: Mark on November 19, 2003, 10:30:11 AM
How about this
Code: [Select]
(vl-load-com)
(if (setq fn (getfiled "Select File To Delete" "" "" 8))
    (if (vl-file-delete fn)
      (alert (strcat fn " Deleted..."))
      )
   (princ)
    )
Title: deleting files via lisp
Post by: Craig on November 19, 2003, 11:12:54 AM
Vinny,
What version of Autocad are you running? The routine Mark posted will only run in 2000+.
Title: deleting files via lisp
Post by: Craig on November 19, 2003, 11:24:10 AM
Mark, if this runs on its own merit when pasting it on the command line, why in some situations you have to have (vl-load-com) at the start of the program to make it work :?:
Title: deleting files via lisp
Post by: Mark on November 19, 2003, 11:32:42 AM
If you have loaded a program that has (vl-load-com) in it, that will work for the whole ACAD session.

Looks like I'm in violation of the Daron Act.
let me go edit that post real quick before Daron see's it
Title: deleting files via lisp
Post by: Craig on November 19, 2003, 11:36:23 AM
So what you're telling me is I could possibly have Autocad load the (vl-load-com) automatically at the start of a new session
Title: deleting files via lisp
Post by: Mark on November 19, 2003, 11:40:13 AM
sure, do you a custom menu, put (vl-load-com) in your .mnl file. Or any other lisp that runs when ACAD opens.
Title: deleting files via lisp
Post by: Craig on November 19, 2003, 11:45:09 AM
So, have you figured out a way to make mutliple selections in a DCL file list box like such
Code: [Select]
: list_box {
            key = "box_list";
            fixed_width = true;
            allow_accept=true;
            alignment = centered;
            width = 40;


I know how to get single selections but not multiple. Any ideas?
Title: deleting files via lisp
Post by: Craig on November 19, 2003, 12:00:24 PM
Or, is there a vl- comparible to getfiled that will let you select multiple files?
Title: deleting files via lisp
Post by: Mark on November 19, 2003, 12:03:38 PM
Quote
multiple_select = true-false;

Specifies whether multiple items in the list_box can be selected (highlighted) at the same time. Possible values are true or false (default: false). If true, multiple items can be selected at a time.


that should work in your DCL.
Title: deleting files via lisp
Post by: Craig on November 19, 2003, 12:04:43 PM
Damn, where the hell did you run across that. I have been looking and found nothing. You got a book or something?  :o

Thats exactly what I was after. You are my hero!
Title: deleting files via lisp
Post by: Mark on November 19, 2003, 12:08:42 PM
<acad install>\Help\acad_dev.chm I have a shortcut to it in my Taxkbar.

see Programmable Dialog Box Reference
Title: deleting files via lisp
Post by: daron on November 19, 2003, 12:31:39 PM
What do you mean, The Daron act?
Title: deleting files via lisp
Post by: Mark on November 19, 2003, 12:41:13 PM
>What do you mean, The Daron act?
heyheyhey....... you forgot!

see my wise a$$ response about 1/2 way down.

http://www.cadalog.com/phpbb2/viewtopic.php?t=15768&highlight=daron+act
Title: deleting files via lisp
Post by: daron on November 19, 2003, 12:50:41 PM
Yup! I totally forgot. That's funny. You want to post that in Lagniappe under the heading of "By-laws of The Swamp"?
Title: deleting files via lisp
Post by: Mark on November 19, 2003, 12:51:48 PM
Quote from: Daron
Yup! I totally forgot. That's funny. You want to post that in Lagniappe under the heading of "By-laws of The Swamp"?

Oh hell yea! maybe I'll remember next time.  :shock:
Title: deleting files via lisp
Post by: Columbia on November 19, 2003, 12:58:43 PM
About the multiple select:

One thing to be aware of is what the action_tile $value returns.  On multiple_select=false; conditions the list_box will return a value of the quoted index (i.e. "0" or "3").  But when multiple_select=true; the returned value will be a single string that indicates which index's are selected delimited by a single space (i.e. "1 2 4 7").
Title: deleting files via lisp
Post by: CADaver on November 19, 2003, 05:21:24 PM
I know this is the VLISP hackers forum, and everything goes better with lisp, but....

You can accomplish nearly the same thing with the OPEN dialog box.  Just hightlight the files you want to trash and hit DEL.
Title: deleting files via lisp
Post by: SMadsen on November 19, 2003, 05:30:42 PM
Maybe it should be accomplished automatically? :)

As a last resort you can always shell out through AutoCAD and do it:

(command "SHELL" "Del C:\\hello.lsp")

or

(command "DEL" "C:\\hello.lsp")  <-- also check out the pgp file for DOS commands