(setq freespace(rtos

Discussion in 'AutoCAD' started by coachball8, Jul 13, 2004.

  1. coachball8

    coachball8 Guest

    (setq freespace (rtos (caddr (dos_chkdsk "d:\\")) 2 0))
    (setq dwg (getvar "dwgname")file_size1 (vl-file-size (strcat (getvar "dwgprefix") dwg))
    (setq size (vl-princ-to-string file_size1))

    I need to compare these two, and if the dwg size is larger than than the free disk space, pause to change disks. Is it possible and if so how do I achieve it? I may not be using the best approach for this. Any suggestions are appreciated. TIA
     
    coachball8, Jul 13, 2004
    #1
  2. coachball8

    ECCAD Guest

    Coach,
    Try this:
    ;; Check for disk space..
    (vl-load-com)

    (defun check_disk ( disk / dwg file_size1)
    (setq freespace (rtos (caddr (dos_chkdsk (strcat disk "\\"))) 2 0))
    (setq dwg (getvar "dwgname"))
    (setq file_size1 (vl-file-size (strcat (getvar "dwgprefix") dwg)))
    (setq size (vl-princ-to-string file_size1))
    ;; change 'freespace' and 'size' to numbers..
    (setq freespace (atoi freespace))
    (setq size (atoi size))
    (princ)
    ); function

    (defun C:CD ()
    (check_disk "A:")
    ;; Debug
    (prompt (strcat "\nDisk Free Space = " (rtos freespace)))
    (prompt (strcat "\nDrawing Size = " (rtos size)))
    ;; Check if drawing size (size) > freespace
    (if (> freespace size)
    (progn
    (prompt "\nDiskspace is larger than Drawing Size, OK to save..")
    (princ)
    ); progn
    (progn
    (prompt "\nDrawing will not fit on Disk")
    (princ)
    ); progn
    ); if
    ;;
    (while (> size freespace)
    (alert "Drawing will not fit on Disk, Please change the Disk")
    (check_disk "A:")
    ); while
    (princ)
    ); function

    Bob
     
    ECCAD, Jul 13, 2004
    #2
  3. coachball8

    coachball8 Guest

    Bob, you're the man! I've been struggling with this off and on in my spare time for a couple of months now. I was missing the (atoi) trying to do it with (rtos). Thanks a bunch!
     
    coachball8, Jul 13, 2004
    #3
  4. coachball8

    ECCAD Guest

    Yes,
    Strings are strings..numbers are numbers..a little tricky.
    But, I still have a few tricks up my sleeve.

    Cheers :)

    Bob
     
    ECCAD, Jul 13, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.