Author Topic: Little Help with Findfile? Possibly  (Read 1556 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Little Help with Findfile? Possibly
« on: March 21, 2017, 09:56:36 AM »
I'm a little off here and I'm sure it's simple but I need this bit of code to check for the existance of a file (ProjInfo.txt) and if found continue to run and open the file. And if it does not find it in the current path, Alert the user that it does not exist. I hope I explained myself.

Code: [Select]
(setq DV:GETPROJ (strcat (getvar "dwgprefix")))
(setq DV:EXISTS (vl-directory-files DV:GETPROJ "projinfo.txt"))
(if (= DV:GETPROJ nil)
          (alert "\nThe drawing DOES NOT have a the ProjInfo.txt in the job folder!!!!!!!!!")
     (setq filefp (open (strcat (getvar "dwgprefix") "projinfo.txt") "r"))
)

Thanks,
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Little Help with Findfile? Possibly
« Reply #1 on: March 21, 2017, 10:25:11 AM »
Code - Auto/Visual Lisp: [Select]
  1. (if (findfile (strcat (getvar 'dwgprefix) "projinfo.txt"))
  2.   (alert (strcat (getvar 'dwgprefix) "projinfo.txt found..."))
  3.   (alert (strcat (getvar 'dwgprefix) "projinfo.txt not found..."))
  4. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Little Help with Findfile? Possibly
« Reply #2 on: March 23, 2017, 09:32:20 AM »
Quote
(if (findfile (strcat (getvar 'dwgprefix) "projinfo.txt"))
  (alert (strcat (getvar 'dwgprefix) "projinfo.txt found..."))
  (alert (strcat (getvar 'dwgprefix) "projinfo.txt not found..."))
)

Thanks ronjonp

I appreciate it.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Little Help with Findfile? Possibly
« Reply #3 on: March 23, 2017, 09:39:04 AM »
Quote
(if (findfile (strcat (getvar 'dwgprefix) "projinfo.txt"))
  (alert (strcat (getvar 'dwgprefix) "projinfo.txt found..."))
  (alert (strcat (getvar 'dwgprefix) "projinfo.txt not found..."))
)

Thanks ronjonp

I appreciate it.
Glad to help  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC