Jebus_kfc Posted August 4, 2010 Posted August 4, 2010 I am helping a friend with a program that will log certain information in a word file, and it will tell time in military time and he would rather have it in standard time. So I figured I could fix it but I am stuck with this strcat function. If anyone could help that would be much appriciated. Problem as follows: (defun c:track (/ V1 TM TIME MO DAY YR hour minute DATE LN DP DN TX) (setq DES (getstring T"\n Enter Brief Description of Work Performed: ")) (setq V1 (menucmd "M=$(edtime, $(getvar,date),DDDD)") TM (menucmd "M=$(edtime, $(getvar,date),hh:mm:ss)") MO (menucmd "M=$(edtime, $(getvar,date),MOnth)") DAY (menucmd "M=$(edtime, $(getvar,date),DD)") YR (menucmd "M=$(edtime, $(getvar,date),yyyy)") HOUR (ATOI(substr TM 1 2)) MINUTE (atoi(substr TM 3 2)) ;;; DATE (ATOI(strcat V1 ", " MO " " DAY ", " YR)) ) (cond (( ((> HOUR 12) (setq TIME (- HOUR 12))) );cond ;;;(setq DATE (itoa(strcat V1 ", " MO " " DAY " " YR " " TIME ":" MINUTE))) (setq DATE (strcat V1 ", " MO " " DAY " " YR " " TIME MINUTE)) (setq LN (getvar "loginname")) (setq DP (getvar "dwgprefix")) (setq DN (getvar "dwgname")) (setq TX (open "c:\\logs\\track.txt" "a")) (write-line "" TX) (write-line "-----------------------------------" TX) (write-line "" TX) (write-line Date TX) (write-line LN TX) (write-line DP TX) (write-line DN TX) (write-line "" TX) (write-line "Description:" TX) (write-line DES TX) (close TX) (princ) );eop Quote
Lee Mac Posted August 4, 2010 Posted August 4, 2010 Give this a shot mate: (defun c:track ( / Desc f ) ;; © Lee Mac 2010 (setq Desc (getstring t "\n Enter Brief Description of Work Performed: ")) (cond ( (setq f (open "c:\\logs\\track.txt" "a")) (mapcar '(lambda ( s ) (write-line s f)) (list "" "-----------------------------------" "" (toDate "DDDD MO.DD.YYYY HH:MM") (getvar 'loginname) (strcat (getvar 'dwgprefix) (getvar 'dwgname)) "" "Description: " Desc ) ) (close f) ) ) (princ) ) (defun toDate ( format ) (menucmd (strcat "m=$(edtime,$(getvar,DATE)," format ")"))) Your problem was the conversion of the Hours and Minutes back to a string. BTW, bear in mind code assumes folder 'logs' exists - perhaps look into vl-mkdir Lee Quote
Lee Mac Posted August 4, 2010 Posted August 4, 2010 Oh, and see here also: http://www.cadtutor.net/forum/showthread.php?9184-Code-posting-guidelines Quote
Jebus_kfc Posted August 4, 2010 Author Posted August 4, 2010 thanks for the tips... the program you gave works wonderfull, except I was wanting to change just the hour from military time to standard time... for the out put only, ex: from 13:48 to 1:48. If we could make just the hour a variable then : (cond ((< HOUR 12) (setq TIME HOUR)) ((> HOUR 12) (setq TIME (- HOUR 12))) );cond could be used to change it. -thanks Quote
Lee Mac Posted August 4, 2010 Posted August 4, 2010 (defun c:track ( / Desc f ) ;; © Lee Mac 2010 (setq Desc (getstring t "\n Enter Brief Description of Work Performed: ")) (cond ( (setq f (open "c:\\logs\\track.txt" "a")) (mapcar '(lambda ( s ) (write-line s f)) (list "" "-----------------------------------" "" (strcat (toDate "DDDD MO.DD.YYYY") " " ((lambda ( h ) (itoa (if (< 12 h) (- h 12) h))) (atoi (toDate "HH"))) (toDate ":MM") ) (getvar 'loginname) (strcat (getvar 'dwgprefix) (getvar 'dwgname)) "" "Description: " Desc ) ) (close f) ) ) (princ) ) (defun toDate ( format ) (menucmd (strcat "m=$(edtime,$(getvar,DATE)," format ")"))) Quote
Jebus_kfc Posted August 4, 2010 Author Posted August 4, 2010 wow!!! good job it works... thanks a bunch... is there any web sights or books you could refer to me for more advanced programming??? Quote
Lee Mac Posted August 4, 2010 Posted August 4, 2010 You're welcome mate I posted a bunch of links here, some may be of use: http://www.cadtutor.net/forum/showthread.php?49515-Useful-LISP-Links Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.