How to handle no file found?

Discussion in 'AutoCAD' started by mnelson, Jun 23, 2004.

  1. mnelson

    mnelson Guest

    I’m using the lines below to load routines for specific users. I’d like to have some error control to it. Let’s say the file is not found – how can I pass the error and not have the routine blow. You can see I some a type of file not found handler in the last routine below, but don’t know how to combine them. Any ideas? Any suggestion for something other then what I have here?

    Thanks

    (if (= (getvar "loginname") "DSMITH")
    (load "H:\\Production\\Acad\\AFMTools\\Entclean")
    )

    (if (findfile "H:\\Production\\Acad\\Shortcom.lsp")
    (load "H:\\Production\\Acad\\Shortcom.lsp")
    )
    )
     
    mnelson, Jun 23, 2004
    #1
  2. mnelson

    ECCAD Guest

    (if (findfile "H:\\Production\\Acad\\Shortcom.lsp")
    (load "H:\\Production\\Acad\\Shortcom.lsp")
    (alert "\nCould not find H:\\Production\\Acad\\Shortcom.lsp file ?")
    )


    Bob
     
    ECCAD, Jun 23, 2004
    #2
  3. mnelson

    mnelson Guest

    Oh, I see, but how do I get the load per user "if" and "if" file found all in one routine?
     
    mnelson, Jun 23, 2004
    #3
  4. (if (= (getvar "loginname") "DSMITH")
    (if (findfile"H:\\Production\\Acad\\AFMTools\\Entclean")
    (load "H:\\Production\\Acad\\AFMTools\\Entclean")
    (princ "\nEntclean.lsp Not Found")
    )
    (princ "\nNot User DSmith")
    )
     
    Alan Henderson @ A'cad Solutions, Jun 23, 2004
    #4
  5. mnelson

    ECCAD Guest

    You mean like this ?

    (if (= (getvar "loginname") "DSMITH")
    (progn
    (load "H:\\Production\\Acad\\AFMTools\\Entclean")
    (if (findfile "H:\\Production\\Acad\\Shortcom.lsp")
    (load "H:\\Production\\Acad\\Shortcom.lsp")
    (alert "\nCould not find H:\\Production\\Acad\\Shortcom.lsp file ?")
    ); end progn
    ); end if

    You can 'nest' all findfile....'s within a structure like:
    (if (condition..)
    (progn
    (do this)
    (and this)
    (and this)
    ); end progn
    ); end if

    OR
    (if (condition...)
    (progn
    (do this)
    (and this)
    ); end progn
    (don't do this)
    ); end if

    Bob
     
    ECCAD, Jun 23, 2004
    #5
  6. mnelson

    Rudy Tovar Guest

    (if
    (and
    (= (getvar "loginname") "DSMITH"))
    (findfile "H:\\Production\\Acad\\AFMTools\\Entclean")
    )
    (progn
    (load "H:\\Production\\Acad\\AFMTools\\Entclean")
    (if (findfile "H:\\Production\\Acad\\Shortcom.lsp")
    (load "H:\\Production\\Acad\\Shortcom.lsp")
    )
    )
    )
    )
    ;Endless possibilities, but only one solution, yours...
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi


    have some error control to it. Let's say the file is not found - how can I
    pass the error and not have the routine blow. You can see I some a type of
    file not found handler in the last routine below, but don't know how to
    combine them. Any ideas? Any suggestion for something other then what I have
    here?
     
    Rudy Tovar, Jun 23, 2004
    #6
  7. mnelson

    mnelson Guest

    Thanks for all the info above. Gives me good options.
     
    mnelson, Jun 24, 2004
    #7
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.