ok new situation,
using the following code (thanks again for the help)
i have the code reading a line in a text file in order to compare the time the file has been modified last and then it writes the new time back to the text file for comparison the next time its modified.
I have 5 stations that need to run this lisp to let them know of any changes
if one station runs the lisp it writes back to the text file the last time the file was changed and therefore the next station who runs this lisp wont know of the changes.
which brings me to the next question.
does anyone have an idea on how i can get this to run on 5 stations without writing back untill ever station that is turned on, has ran it?
i thought of using the getvar loginname function and setting it for after i run it, it writes back, but lets say if im on vacation or out of the day, how could it write back when its just say 3 stations operating?
any thoughts are appreciated
here is the code
(defun c:stkchkfile (/ filePath dateList hour cmdecho check_file_time check_file) ;filePath dateList hour
;;******* check for user data file last recorded modification time
(defun readfile (filename / f path line lst) ;f path line lst
(setq user_data_file (findfile "acad_user_data.txt"))
(if (setq path user_data_file)
(cond
((setq f (open path "r"))
(while (setq line (read-line f))
(setq lst (cons line lst))
)
(close f)
(reverse lst)
)
) ; end cond
) ; end if
) ; end defun
;;*********** check for stock file modification date and time
(terpri)
(if (setq filePath "F:/stock/partdes.txt")
(setq check_file
(strcat
"Stock book was last modified on: "
(itoa (cadr (setq dateList (vl-file-systime filePath))))
"-"
(itoa (nth 3 dateList))
"-"
(itoa (car dateList))
", at "
(cond
((<= 12 (setq hour (nth 4 dateList)))
(strcat
(if (= 12 hour)
(itoa hour)
(itoa (- hour 12))
)
":"
(itoa (nth 5 dateList))
" PM")
)
((strcat (itoa hour) ":" (itoa (nth 5 dateList)) " AM"))
) ; end cond
"\n Please check your part numbers"
) ; end strcat
) ; end setq
) ; end if
(setq check_file_time
(cond
((<= 12 (setq hour (nth 4 dateList)))
(strcat
(if (= 12 hour)
(itoa hour)
(itoa (- hour 12))
)
":"
(itoa (nth 5 dateList))
" PM"
)
)
((strcat (itoa hour) ":" (itoa (nth 5 dateList)) " AM")))
)
(terpri)
(princ)
;;********* send alert if file has been modified
;; Ensure OpenDCL Runtime is (quietly) loaded
(setq cmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "_OPENDCL")
(setvar "CMDECHO" cmdecho)
; call the method to load the odcl file.
(dcl_Project_Load "stkfilecheck" T)
(if (setq lst (readfile user_data_file))
(setq last_mod (nth 0 lst))
)
(if (/= check_file_time last_mod)
(dcl_MessageBox check_file "Stockbook file checker" 2 1)
)
;;******** write back new modification time
(SETQ last_mod (SUBST check_file_time (NTH 0 lst) lst))
(SETQ m_file user_data_file)
(setq o_file (open m_file "w"))
(write-line (nth 0 last_mod) o_file)
(close o_file)
(terpri)
(princ)
) ;end