Time Logging ... Need some help w/ code
Time Logging ... Need some help w/ code
(OP)
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)
RE: Time Logging ... Need some help w/ code
Can you be more clear on what is happening, & what you want it to do?
RE: Time Logging ... Need some help w/ code
I need the lisp to generate a daily date so i can keep a daily log of what i worked on
[code} (open "C:\\Users\\Acad2015\\TimeLog\\Logfile-(date).txt" "w")[/code]
Then I will want the output text file to look like this ....
Drawing Started 04/24/15 - 08:53:19 - Holliday_Parlor_Rev0.dwg
Drawing Exit 04/24/15 - 08:53:43 - Holliday_Parlor_Rev0.dwg
Editing Time This Session : 0.0000 Hours and 0.4000 minutes
==============================================================
Drawing Started 04/24/15 - 08:53:19 - Holliday_LivingRm_Rev0.dwg
Drawing Exit 04/24/15 - 08:53:43 - Holliday_LivingRm_Rev0.dwg
Editing Time This Session : 0.0000 Hours and 0.4000 minutes
==============================================================
RE: Time Logging ... Need some help w/ code
Because the 1st line of code is telling to write the file every time you run the login part of the lisp then every part after that it appends to it.
and the date part i just want it so I have a daily log ... and thanks Carl for the help if you can give it
Joey G
RE: Time Logging ... Need some help w/ code
It needs just a simple change.
Insert 1 line and edit one line.
CODE -->
RE: Time Logging ... Need some help w/ code
Logfile-042415.txt ?
Thank you for that help !!! ... This is just perfect !!
RE: Time Logging ... Need some help w/ code
findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile-" (toDate "DATE" "MODDYY") ".txt"))
This is the code i have so you can test it .... let me know .. Joey
CODE -->
RE: Time Logging ... Need some help w/ code
Your edits had some lisp syntax problems, but the general approach works okay.
CODE -->
RE: Time Logging ... Need some help w/ code
I hope this is something you can use also ... I made to icons for a start and stop and its PERFECT !!!
Thank you for the clean up and now i see how you defined it and its just spot on
Thanks again
Joey G