Joeyg77
Computer
- Apr 24, 2015
- 6
I need help with this code ... I need it to have a daily log. If you run the list it over writes the file already there. I need it to return the after every entry and then i need the file to generate the date so it will have a running log of files in the folder. Take a look and let me know
Thanks Joey G
Thanks Joey G
Code:
;;;*This is a Drawing Log Routine that logs the date, time, &
;;;*Drawing Name of each Drawing Session. It writes a report
;;;*to an ASCII Text file (Log.Txt).
;;;*If you wish you can load Login.Lsp from your Acad.Lsp file,
;;;*and edit the Acad.mnu to call the Logout.Lsp routine before
;;;*Exiting, Quiting or starting a new drawing.
;;;*Author: Kenny Ramage
;;;*============================================================
(defun C:LOGIN ( / a c d file fp)
(if (not file)
(open "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt" "w")
);if
(setq a (TODAY)
TIME1 (TIME)
c (getvar "DWGNAME")
d (strcat "Drawing Started " a " - " TIME1 " - " c)
);setq
(if (/= c "Drawing.dwg")
(progn
(setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt")
fp (open file "a")
);setq
(princ d fp)
(princ "\n" fp)
(close fp)
(princ (strcat "\nLogged in at : " TIME1))
);progn
);if
(princ)
);defun
;;;*-------------------------------------------------
(defun C:LOGOUT ( / a c d file fp)
(setq a (TODAY)
TIME2 (TIME)
c (getvar "DWGNAME")
d (strcat "Drawing Exit " a " - " TIME2 " - " c)
);setq
(if (/= c "Drawing.dwg")
(progn
(setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt")
fp (open file "a")
);setq
(princ d fp)
(princ "\n" fp)
(close fp)
(princ (strcat "\nLogged out at : " TIME2))
(etime)
);progn
);if
(princ)
);defun
;;;*-------------------------------------------------
(defun ETIME ( / hr1 m1 s1 tot1 hr2 m2 s2 tot2 total ht mt file fp)
(setq hr1 (* 60 (* 60 (atof (substr time1 1 2))))
m1 (* 60 (atof (substr time1 4 2)))
s1 (atof (substr time1 7 2))
tot1 (+ hr1 m1 s1)
hr2 (* 3600 (atof (substr time2 1 2)))
m2 (* 60 (atof (substr time2 4 2)))
s2 (atof (substr time2 7 2))
tot2 (+ hr2 m2 s2)
total (- tot2 tot1)
hr1 (/ total 3600)
ht (fix hr1)
hr1 (- hr1 ht)
mt (* hr1 60)
ht (rtos ht)
mt (rtos mt)
);setq
(setq d (strcat "Editing Time This Session : " ht " Hours and " mt " minutes"))
(setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt")
fp (open file "a")
);setq
(princ d fp)
(princ "\n" fp)
(princ "==============================================================" fp )
(princ "\n" fp)
(close fp)
(princ)
);defun
;;;*-------------------------------------------
;;;*Calculates the Current Date
(defun TODAY ( / d yr mo day)
(setq d (rtos (getvar "CDATE") 2 6)
yr (substr d 3 2)
mo (substr d 5 2)
day (substr d 7 2)
);setq
(strcat mo "/" day "/" yr)
);defun
;;;*-------------------------------------------
;;;*Calculates the Current Time
(defun TIME ( / d hr m s)
(setq d (rtos (getvar "CDATE") 2 6)
hr (substr d 10 2)
m (substr d 12 2)
s (substr d 14 2)
);setq
(strcat hr ":" m ":" s)
);defun
(princ)