Author Topic: deleting files via lisp  (Read 12761 times)

0 Members and 1 Guest are viewing this topic.

vinnyg

  • Guest
deleting files via lisp
« 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:

Craig

  • Guest
deleting files via lisp
« Reply #1 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.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
deleting files via lisp
« Reply #2 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)
    )
TheSwamp.org  (serving the CAD community since 2003)

Craig

  • Guest
deleting files via lisp
« Reply #3 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+.

Craig

  • Guest
deleting files via lisp
« Reply #4 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 :?:

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
deleting files via lisp
« Reply #5 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
TheSwamp.org  (serving the CAD community since 2003)

Craig

  • Guest
deleting files via lisp
« Reply #6 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

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
deleting files via lisp
« Reply #7 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.
TheSwamp.org  (serving the CAD community since 2003)

Craig

  • Guest
deleting files via lisp
« Reply #8 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?

Craig

  • Guest
deleting files via lisp
« Reply #9 on: November 19, 2003, 12:00:24 PM »
Or, is there a vl- comparible to getfiled that will let you select multiple files?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
deleting files via lisp
« Reply #10 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.
TheSwamp.org  (serving the CAD community since 2003)

Craig

  • Guest
deleting files via lisp
« Reply #11 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!

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
deleting files via lisp
« Reply #12 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
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
deleting files via lisp
« Reply #13 on: November 19, 2003, 12:31:39 PM »
What do you mean, The Daron act?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
deleting files via lisp
« Reply #14 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
TheSwamp.org  (serving the CAD community since 2003)